annotate DEPENDENCIES/generic/include/boost/python/detail/string_literal.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright David Abrahams 2002.
Chris@16 2 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 3 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 4 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 5 #ifndef STRING_LITERAL_DWA2002629_HPP
Chris@16 6 # define STRING_LITERAL_DWA2002629_HPP
Chris@16 7
Chris@16 8 # include <cstddef>
Chris@16 9 # include <boost/type.hpp>
Chris@16 10 # include <boost/type_traits/array_traits.hpp>
Chris@16 11 # include <boost/type_traits/same_traits.hpp>
Chris@16 12 # include <boost/mpl/bool.hpp>
Chris@16 13 # include <boost/detail/workaround.hpp>
Chris@16 14
Chris@16 15 namespace boost { namespace python { namespace detail {
Chris@16 16
Chris@16 17 # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Chris@16 18 template <class T>
Chris@16 19 struct is_string_literal : mpl::false_
Chris@16 20 {
Chris@16 21 };
Chris@16 22
Chris@16 23 # if !defined(__MWERKS__) || __MWERKS__ > 0x2407
Chris@16 24 template <std::size_t n>
Chris@16 25 struct is_string_literal<char const[n]> : mpl::true_
Chris@16 26 {
Chris@16 27 };
Chris@16 28
Chris@16 29 # if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590040)) \
Chris@16 30 || (defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730)
Chris@16 31 // This compiler mistakenly gets the type of string literals as char*
Chris@16 32 // instead of char[NN].
Chris@16 33 template <>
Chris@16 34 struct is_string_literal<char* const> : mpl::true_
Chris@16 35 {
Chris@16 36 };
Chris@16 37 # endif
Chris@16 38
Chris@16 39 # else
Chris@16 40
Chris@16 41 // CWPro7 has trouble with the array type deduction above
Chris@16 42 template <class T, std::size_t n>
Chris@16 43 struct is_string_literal<T[n]>
Chris@16 44 : is_same<T, char const>
Chris@16 45 {
Chris@16 46 };
Chris@16 47 # endif
Chris@16 48 # else
Chris@16 49 template <bool is_array = true>
Chris@16 50 struct string_literal_helper
Chris@16 51 {
Chris@16 52 typedef char (&yes_string_literal)[1];
Chris@16 53 typedef char (&no_string_literal)[2];
Chris@16 54
Chris@16 55 template <class T>
Chris@16 56 struct apply
Chris@16 57 {
Chris@16 58 typedef apply<T> self;
Chris@16 59 static T x;
Chris@16 60 static yes_string_literal check(char const*);
Chris@16 61 static no_string_literal check(char*);
Chris@16 62 static no_string_literal check(void const volatile*);
Chris@16 63
Chris@16 64 BOOST_STATIC_CONSTANT(
Chris@16 65 bool, value = sizeof(self::check(x)) == sizeof(yes_string_literal));
Chris@16 66 typedef mpl::bool_<value> type;
Chris@16 67 };
Chris@16 68 };
Chris@16 69
Chris@16 70 template <>
Chris@16 71 struct string_literal_helper<false>
Chris@16 72 {
Chris@16 73 template <class T>
Chris@16 74 struct apply : mpl::false_
Chris@16 75 {
Chris@16 76 };
Chris@16 77 };
Chris@16 78
Chris@16 79 template <class T>
Chris@16 80 struct is_string_literal
Chris@16 81 : string_literal_helper<is_array<T>::value>::apply<T>
Chris@16 82 {
Chris@16 83 };
Chris@16 84 # endif
Chris@16 85
Chris@16 86 }}} // namespace boost::python::detail
Chris@16 87
Chris@16 88 #endif // STRING_LITERAL_DWA2002629_HPP