2014-10-23 08:23:38 +00:00
|
|
|
/*=============================================================================
|
2016-02-25 09:48:28 +00:00
|
|
|
Copyright (c) 2011-2016 Bolero MURAKAMI
|
2014-10-23 08:23:38 +00:00
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
=============================================================================*/
|
|
|
|
#ifndef SPROUT_DETAIL_LITERAL_DEF_HPP
|
|
|
|
#define SPROUT_DETAIL_LITERAL_DEF_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/string.hpp>
|
2014-10-27 01:16:49 +00:00
|
|
|
#include <sprout/type_traits/integral_constant.hpp>
|
2014-10-23 08:23:38 +00:00
|
|
|
#include <sprout/preprocessor/cat.hpp>
|
|
|
|
|
|
|
|
//
|
|
|
|
// SPROUT_LITERAL_STRING_DEF
|
|
|
|
//
|
|
|
|
#if SPROUT_USE_UNICODE_LITERALS
|
|
|
|
# define SPROUT_LITERAL_STRING_DEF(NAME, STRING, LENGTH) \
|
2016-03-08 09:22:38 +00:00
|
|
|
template<typename Elem, typename X = void> \
|
2014-10-23 08:23:38 +00:00
|
|
|
struct NAME; \
|
|
|
|
SPROUT_LITERAL_STRING_DEF_IMPL(NAME, STRING, LENGTH, char); \
|
|
|
|
SPROUT_LITERAL_STRING_DEF_IMPL(NAME, SPROUT_PP_CAT(L, STRING), LENGTH, wchar_t); \
|
|
|
|
SPROUT_LITERAL_STRING_DEF_IMPL(NAME, SPROUT_PP_CAT(u, STRING), LENGTH, char16_t); \
|
|
|
|
SPROUT_LITERAL_STRING_DEF_IMPL(NAME, SPROUT_PP_CAT(U, STRING), LENGTH, char32_t); \
|
2016-03-08 09:22:38 +00:00
|
|
|
template<typename Elem, typename X> \
|
2014-10-23 08:23:38 +00:00
|
|
|
struct NAME {}
|
|
|
|
#else
|
|
|
|
# define SPROUT_LITERAL_STRING_DEF(NAME, STRING, LENGTH) \
|
2016-03-08 09:22:38 +00:00
|
|
|
template<typename Elem, typename X = void> \
|
2014-10-23 08:23:38 +00:00
|
|
|
struct NAME; \
|
|
|
|
SPROUT_LITERAL_STRING_DEF_IMPL(NAME, STRING, LENGTH, char); \
|
|
|
|
SPROUT_LITERAL_STRING_DEF_IMPL(NAME, SPROUT_PP_CAT(L, STRING), LENGTH, wchar_t); \
|
2016-03-08 09:22:38 +00:00
|
|
|
template<typename Elem, typename X> \
|
2014-10-23 08:23:38 +00:00
|
|
|
struct NAME {}
|
|
|
|
#endif
|
|
|
|
#define SPROUT_LITERAL_STRING_DEF_IMPL(NAME, STRING, LENGTH, ELEM) \
|
2016-03-08 09:22:38 +00:00
|
|
|
template<typename X> \
|
|
|
|
struct NAME<ELEM, X> { \
|
2014-10-23 08:23:38 +00:00
|
|
|
public: \
|
|
|
|
SPROUT_STATIC_CONSTEXPR sprout::basic_string<ELEM, LENGTH> value \
|
2016-03-08 09:22:38 +00:00
|
|
|
SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_INNER(sprout::to_string(STRING)) \
|
2014-10-23 08:23:38 +00:00
|
|
|
; \
|
|
|
|
}; \
|
2016-03-08 09:22:38 +00:00
|
|
|
template<typename X> \
|
|
|
|
SPROUT_CONSTEXPR_OR_CONST sprout::basic_string<ELEM, LENGTH> NAME<ELEM, X>::value \
|
|
|
|
SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(sprout::to_string(STRING))
|
2014-10-23 08:23:38 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// SPROUT_LITERAL_CHAR_DEF
|
|
|
|
//
|
|
|
|
#if SPROUT_USE_UNICODE_LITERALS
|
|
|
|
# define SPROUT_LITERAL_CHAR_DEF(NAME, CHAR) \
|
|
|
|
template<typename Elem> \
|
|
|
|
struct NAME; \
|
|
|
|
SPROUT_LITERAL_CHAR_DEF_IMPL(NAME, CHAR, char); \
|
|
|
|
SPROUT_LITERAL_CHAR_DEF_IMPL(NAME, SPROUT_PP_CAT(L, CHAR), wchar_t); \
|
|
|
|
SPROUT_LITERAL_CHAR_DEF_IMPL(NAME, SPROUT_PP_CAT(u, CHAR), char16_t); \
|
|
|
|
SPROUT_LITERAL_CHAR_DEF_IMPL(NAME, SPROUT_PP_CAT(U, CHAR), char32_t); \
|
|
|
|
template<typename Elem> \
|
|
|
|
struct NAME {}
|
|
|
|
#else
|
|
|
|
# define SPROUT_LITERAL_CHAR_DEF(NAME, CHAR) \
|
|
|
|
template<typename Elem> \
|
|
|
|
struct NAME; \
|
|
|
|
SPROUT_LITERAL_CHAR_DEF_IMPL(NAME, CHAR, char); \
|
|
|
|
SPROUT_LITERAL_CHAR_DEF_IMPL(NAME, SPROUT_PP_CAT(L, CHAR), wchar_t); \
|
|
|
|
template<typename Elem> \
|
|
|
|
struct NAME {}
|
|
|
|
#endif
|
|
|
|
#define SPROUT_LITERAL_CHAR_DEF_IMPL(NAME, CHAR, ELEM) \
|
|
|
|
template<> \
|
2014-10-27 01:16:49 +00:00
|
|
|
struct NAME<ELEM> \
|
|
|
|
: public sprout::integral_constant<ELEM, CHAR> \
|
|
|
|
{}
|
2014-10-23 08:23:38 +00:00
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_DETAIL_LITERAL_DEF_HPP
|