/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. #ifndef BOOST_XPRESSIVE_DETAIL_UTILITY_LITERALS_HPP_EAN_10_04_2005
  8. #define BOOST_XPRESSIVE_DETAIL_UTILITY_LITERALS_HPP_EAN_10_04_2005
  9. // MS compatible compilers support #pragma once
  10. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  11. # pragma once
  12. #endif
  13. #include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
  14. #include <boost/cstdint.hpp> // for BOOST_STATIC_CONSTANT
  15. #include <boost/detail/workaround.hpp>
  16. namespace boost { namespace xpressive { namespace detail
  17. {
  18. ///////////////////////////////////////////////////////////////////////////////
  19. // char_literal
  20. //
  21. template<typename Char, boost::intmax_t Ch, boost::intmax_t Wch>
  22. struct char_literal;
  23. template<typename Char, boost::intmax_t Ch>
  24. struct char_literal<Char, Ch, Ch>
  25. {
  26. BOOST_STATIC_CONSTANT(boost::intmax_t, value = Ch);
  27. };
  28. #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
  29. template<typename Char, boost::intmax_t Ch>
  30. boost::intmax_t const char_literal<Char, Ch, Ch>::value;
  31. #endif
  32. template<typename Ch>
  33. struct string_literal;
  34. template<>
  35. struct string_literal<char>
  36. {
  37. static char const *pick(char const *cstr, wchar_t const *)
  38. {
  39. return cstr;
  40. }
  41. static char pick(char ch, wchar_t)
  42. {
  43. return ch;
  44. }
  45. };
  46. template<>
  47. struct string_literal<wchar_t>
  48. {
  49. static wchar_t const *pick(char const *, wchar_t const *cstr)
  50. {
  51. return cstr;
  52. }
  53. static wchar_t pick(char, wchar_t ch)
  54. {
  55. return ch;
  56. }
  57. };
  58. #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
  59. # define BOOST_XPR_CHAR_(Char, ch) ch
  60. # define BOOST_XPR_CSTR_(Char, st) boost::xpressive::detail::string_literal<Char>::pick(st, L##st)
  61. #else
  62. # define BOOST_XPR_CHAR_(Char, ch) boost::xpressive::detail::char_literal<Char, ch, L##ch>::value
  63. # define BOOST_XPR_CSTR_(Char, st) boost::xpressive::detail::string_literal<Char>::pick(st, L##st)
  64. #endif
  65. }}} // namespace boost::xpressive::detail
  66. #endif