]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/xpressive/include/boost/xpressive/detail/utility/literals.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / xpressive / include / boost / xpressive / detail / utility / literals.hpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // literals.hpp
3 //
4 // Copyright 2008 Eric Niebler. Distributed under the Boost
5 // Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8 #ifndef BOOST_XPRESSIVE_DETAIL_UTILITY_LITERALS_HPP_EAN_10_04_2005
9 #define BOOST_XPRESSIVE_DETAIL_UTILITY_LITERALS_HPP_EAN_10_04_2005
10
11 // MS compatible compilers support #pragma once
12 #if defined(_MSC_VER)
13 # pragma once
14 #endif
15
16 #include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
17 #include <boost/cstdint.hpp> // for BOOST_STATIC_CONSTANT
18 #include <boost/detail/workaround.hpp>
19
20 namespace boost { namespace xpressive { namespace detail
21 {
22
23 ///////////////////////////////////////////////////////////////////////////////
24 // char_literal
25 //
26 template<typename Char, boost::intmax_t Ch, boost::intmax_t Wch>
27 struct char_literal;
28
29 template<typename Char, boost::intmax_t Ch>
30 struct char_literal<Char, Ch, Ch>
31 {
32 BOOST_STATIC_CONSTANT(boost::intmax_t, value = Ch);
33 };
34
35 #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
36 template<typename Char, boost::intmax_t Ch>
37 boost::intmax_t const char_literal<Char, Ch, Ch>::value;
38 #endif
39
40 template<typename Ch>
41 struct string_literal;
42
43 template<>
44 struct string_literal<char>
45 {
46 static BOOST_CONSTEXPR char const *pick(char const *cstr, wchar_t const *)
47 {
48 return cstr;
49 }
50
51 static BOOST_CONSTEXPR char pick(char ch, wchar_t)
52 {
53 return ch;
54 }
55 };
56
57 template<>
58 struct string_literal<wchar_t>
59 {
60 static BOOST_CONSTEXPR wchar_t const *pick(char const *, wchar_t const *cstr)
61 {
62 return cstr;
63 }
64
65 static BOOST_CONSTEXPR wchar_t pick(char, wchar_t ch)
66 {
67 return ch;
68 }
69 };
70
71 #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
72
73 # define BOOST_XPR_CHAR_(Char, ch) ch
74 # define BOOST_XPR_CSTR_(Char, st) boost::xpressive::detail::string_literal<Char>::pick(st, L##st)
75
76 #else
77
78 # define BOOST_XPR_CHAR_(Char, ch) boost::xpressive::detail::char_literal<Char, ch, L##ch>::value
79 # define BOOST_XPR_CSTR_(Char, st) boost::xpressive::detail::string_literal<Char>::pick(st, L##st)
80
81 #endif
82
83 }}} // namespace boost::xpressive::detail
84
85 #endif