PageRenderTime 33ms CodeModel.GetById 26ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/xpressive/detail/utility/literals.hpp

http://hadesmem.googlecode.com/
C++ Header | 85 lines | 56 code | 19 blank | 10 comment | 1 complexity | 477cb2ad968fac005e3fab48e37bb133 MD5 | raw file
 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) && (_MSC_VER >= 1020)
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
20namespace boost { namespace xpressive { namespace detail
21{
22
23///////////////////////////////////////////////////////////////////////////////
24// char_literal
25//
26template<typename Char, boost::intmax_t Ch, boost::intmax_t Wch>
27struct char_literal;
28
29template<typename Char, boost::intmax_t Ch>
30struct char_literal<Char, Ch, Ch>
31{
32    BOOST_STATIC_CONSTANT(boost::intmax_t, value = Ch);
33};
34
35#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
36template<typename Char, boost::intmax_t Ch>
37boost::intmax_t const char_literal<Char, Ch, Ch>::value;
38#endif
39
40template<typename Ch>
41struct string_literal;
42
43template<>
44struct string_literal<char>
45{
46    static char const *pick(char const *cstr, wchar_t const *)
47    {
48        return cstr;
49    }
50
51    static char pick(char ch, wchar_t)
52    {
53        return ch;
54    }
55};
56
57template<>
58struct string_literal<wchar_t>
59{
60    static wchar_t const *pick(char const *, wchar_t const *cstr)
61    {
62        return cstr;
63    }
64
65    static 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