1 // boost cxx11_char_types.hpp --------------------------------------------------------//
3 // Copyright Beman Dawes 2011
5 // Distributed under the Boost Software License, Version 1.0.
6 // See http://www.boost.org/LICENSE_1_0.txt
8 //--------------------------------------------------------------------------------------//
10 // The purpose of this header is to emulate the C++11 char16_t and char32_t //
11 // character and string types so that they can be used in both C++11 and C++03 //
14 // The emulation names use char16/char32 rather than char16_t/char32_t to avoid use //
15 // of names that are keywords in C++11. //
17 // The emulation names are placed in namespace boost, as is usual for Boost C++11 //
18 // emulation names such as those in header <boost/cstdint.hpp>. //
20 // An alternative would would have been to place the C++11 emulation names at global //
21 // scope, and put the C++11 string types in namespace std. That is the approach taken //
22 // by Microsoft Visual Studio 2010, but is controversion with some Boost users and //
23 // developers, and runs counter to usual Boost practice. //
25 // Thanks to Mathias Gaunard and others for discussions leading to the final form //
26 // of these typedefs. //
28 // Boost C++11 C++03 //
29 // ---------------- -------------- -------------------------------- //
30 // boost::char16 char16_t uint16_t //
31 // boost::char32 char32_t uint32_t //
32 // boost::u16string std::u16string std::basic_string<boost::char16> //
33 // boost::u32string std::u32string std::basic_string<boost::char32> //
35 // Uses the typedefs provided by Microsoft Visual C++ 2010 if present //
37 // Thanks to Mathias Gaunard and others for discussions leading to the final form //
38 // of these typedefs. //
40 //--------------------------------------------------------------------------------------//
42 #if !defined(BOOST_CXX11_CHAR_TYPES_HPP)
43 # define BOOST_CXX11_CHAR_TYPES_HPP
45 # include <boost/config.hpp>
46 # include <boost/cstdint.hpp>
52 # if defined(BOOST_NO_CHAR16_T) && (!defined(_MSC_VER) || _MSC_VER < 1600) // 1600 == VC++10
53 typedef boost::uint_least16_t char16;
54 typedef std::basic_string<boost::char16> u16string;
56 typedef char16_t char16;
57 typedef std::u16string u16string;
60 # if defined(BOOST_NO_CHAR32_T) && (!defined(_MSC_VER) || _MSC_VER < 1600) // 1600 == VC++10
61 typedef boost::uint_least32_t char32;
62 typedef std::basic_string<boost::char32> u32string;
64 typedef char32_t char32;
65 typedef std::u32string u32string;
70 #endif // !defined(BOOST_CXX11_CHAR_TYPES_HPP)