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