1 // Copyright David Abrahams 2002.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 #ifndef STRING_LITERAL_DWA2002629_HPP
6 # define STRING_LITERAL_DWA2002629_HPP
9 # include <boost/type.hpp>
10 # include <boost/type_traits/array_traits.hpp>
11 # include <boost/type_traits/same_traits.hpp>
12 # include <boost/mpl/bool.hpp>
13 # include <boost/detail/workaround.hpp>
15 namespace boost
{ namespace python
{ namespace detail
{
17 # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
19 struct is_string_literal
: mpl::false_
23 # if !defined(__MWERKS__) || __MWERKS__ > 0x2407
24 template <std::size_t n
>
25 struct is_string_literal
<char const[n
]> : mpl::true_
29 # if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590040)) \
30 || (defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730)
31 // This compiler mistakenly gets the type of string literals as char*
32 // instead of char[NN].
34 struct is_string_literal
<char* const> : mpl::true_
41 // CWPro7 has trouble with the array type deduction above
42 template <class T
, std::size_t n
>
43 struct is_string_literal
<T
[n
]>
44 : is_same
<T
, char const>
49 template <bool is_array
= true>
50 struct string_literal_helper
52 typedef char (&yes_string_literal
)[1];
53 typedef char (&no_string_literal
)[2];
58 typedef apply
<T
> self
;
60 static yes_string_literal
check(char const*);
61 static no_string_literal
check(char*);
62 static no_string_literal
check(void const volatile*);
64 BOOST_STATIC_CONSTANT(
65 bool, value
= sizeof(self::check(x
)) == sizeof(yes_string_literal
));
66 typedef mpl::bool_
<value
> type
;
71 struct string_literal_helper
<false>
74 struct apply
: mpl::false_
80 struct is_string_literal
81 : string_literal_helper
<is_array
<T
>::value
>::apply
<T
>
86 }}} // namespace boost::python::detail
88 #endif // STRING_LITERAL_DWA2002629_HPP