add_facet.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef BOOST_ARCHIVE_ADD_FACET_HPP
  2. #define BOOST_ARCHIVE_ADD_FACET_HPP
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  8. // add_facet.hpp
  9. // (C) Copyright 2003 Robert Ramey - http://www.rrsd.com .
  10. // Use, modification and distribution is subject to the Boost Software
  11. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. // See http://www.boost.org for updates, documentation, and revision history.
  14. #include <locale>
  15. #include <boost/config.hpp>
  16. #include <boost/detail/workaround.hpp>
  17. // does STLport uses native STL for locales?
  18. #if (defined(__SGI_STL_PORT)&& defined(_STLP_NO_OWN_IOSTREAMS))
  19. // and this native STL lib is old Dinkumware (has not defined _CPPLIB_VER)
  20. # if (defined(_YVALS) && !defined(__IBMCPP__)) || !defined(_CPPLIB_VER)
  21. # define BOOST_ARCHIVE_OLD_DINKUMWARE_BENEATH_STLPORT
  22. # endif
  23. #endif
  24. namespace boost {
  25. namespace archive {
  26. template<class Facet>
  27. inline std::locale *
  28. add_facet(const std::locale &l, Facet * f){
  29. return
  30. #if defined BOOST_ARCHIVE_OLD_DINKUMWARE_BENEATH_STLPORT
  31. // std namespace used for native locale
  32. new std::locale(std::_Addfac(l, f));
  33. #elif BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) // old Dinkumwar
  34. // std namespace used for native locale
  35. new std::locale(std::_Addfac(l, f));
  36. #else
  37. // standard compatible
  38. new std::locale(l, f);
  39. #endif
  40. }
  41. } // namespace archive
  42. } // namespace boost
  43. #undef BOOST_ARCHIVE_OLD_DINKUMWARE_BENEATH_STLPORT
  44. #endif // BOOST_ARCHIVE_ADD_FACET_HPP