add_facet.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  2. // (C) Copyright 2003-2007 Jonathan Turkanis
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  5. // See http://www.boost.org/libs/iostreams for documentation.
  6. // Borrowed from <boost/archive/add_facet.hpp>
  7. #ifndef BOOST_IOSTREAMS_DETAIL_ADD_FACET_HPP_INCLUDED
  8. #define BOOST_IOSTREAMS_DETAIL_ADD_FACET_HPP_INCLUDED
  9. #if defined(_MSC_VER)
  10. # pragma once
  11. #endif
  12. #include <boost/config.hpp> // BOOST_DINKUMWARE_STDLIB.
  13. #include <boost/detail/workaround.hpp>
  14. //------------------Definition of add_facet-----------------------------------//
  15. // Does STLport uses old Dinkumware locale?
  16. #if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && \
  17. defined(_STLP_NO_OWN_IOSTREAMS) \
  18. /**/
  19. # if (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)
  20. # define BOOST_IOSTREMS_STLPORT_WITH_OLD_DINKUMWARE
  21. # endif
  22. #endif
  23. namespace boost { namespace iostreams { namespace detail {
  24. template<class Facet>
  25. inline std::locale add_facet(const std::locale &l, Facet * f)
  26. {
  27. return
  28. #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) || \
  29. defined(BOOST_IOSTREMS_STLPORT_WITH_OLD_DINKUMWARE) \
  30. /**/
  31. std::locale(std::_Addfac(l, f));
  32. #else
  33. // standard compatible
  34. std::locale(l, f);
  35. #endif
  36. }
  37. } } } // End namespaces detail, iostreams, boost.
  38. #endif // #ifndef BOOST_IOSTREAMS_DETAIL_ADD_FACET_HPP_INCLUDED