annotate DEPENDENCIES/generic/include/boost/lambda/detail/is_instance_of.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 // Boost Lambda Library - is_instance_of.hpp ---------------------
Chris@16 2
Chris@16 3 // Copyright (C) 2001 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
Chris@16 4 //
Chris@16 5 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 6 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 //
Chris@16 9 // For more information, see www.boost.org
Chris@16 10
Chris@16 11 // ---------------------------------------------------------------
Chris@16 12
Chris@16 13 #ifndef BOOST_LAMBDA_IS_INSTANCE_OF
Chris@16 14 #define BOOST_LAMBDA_IS_INSTANCE_OF
Chris@16 15
Chris@16 16 #include "boost/config.hpp" // for BOOST_STATIC_CONSTANT
Chris@16 17 #include "boost/type_traits/conversion_traits.hpp" // for is_convertible
Chris@16 18 #include "boost/preprocessor/enum_shifted_params.hpp"
Chris@16 19 #include "boost/preprocessor/repeat_2nd.hpp"
Chris@16 20
Chris@16 21 // is_instance_of --------------------------------
Chris@16 22 //
Chris@16 23 // is_instance_of_n<A, B>::value is true, if type A is
Chris@16 24 // an instantiation of a template B, or A derives from an instantiation
Chris@16 25 // of template B
Chris@16 26 //
Chris@16 27 // n is the number of template arguments for B
Chris@16 28 //
Chris@16 29 // Example:
Chris@16 30 // is_instance_of_2<std::istream, basic_stream>::value == true
Chris@16 31
Chris@16 32 // The original implementation was somewhat different, with different versions
Chris@16 33 // for different compilers. However, there was still a problem
Chris@16 34 // with gcc.3.0.2 and 3.0.3 compilers, which didn't think regard
Chris@16 35 // is_instance_of_N<...>::value was a constant.
Chris@16 36 // John Maddock suggested the way around this problem by building
Chris@16 37 // is_instance_of templates using boost::is_convertible.
Chris@16 38 // Now we only have one version of is_instance_of templates, which delagate
Chris@16 39 // all the nasty compiler tricks to is_convertible.
Chris@16 40
Chris@16 41 #define BOOST_LAMBDA_CLASS(z, N,A) BOOST_PP_COMMA_IF(N) class
Chris@16 42 #define BOOST_LAMBDA_CLASS_ARG(z, N,A) BOOST_PP_COMMA_IF(N) class A##N
Chris@16 43 #define BOOST_LAMBDA_ARG(z, N,A) BOOST_PP_COMMA_IF(N) A##N
Chris@16 44
Chris@16 45 #define BOOST_LAMBDA_CLASS_LIST(n, NAME) BOOST_PP_REPEAT(n, BOOST_LAMBDA_CLASS, NAME)
Chris@16 46
Chris@16 47 #define BOOST_LAMBDA_CLASS_ARG_LIST(n, NAME) BOOST_PP_REPEAT(n, BOOST_LAMBDA_CLASS_ARG, NAME)
Chris@16 48
Chris@16 49 #define BOOST_LAMBDA_ARG_LIST(n, NAME) BOOST_PP_REPEAT(n, BOOST_LAMBDA_ARG, NAME)
Chris@16 50
Chris@16 51 namespace boost {
Chris@16 52 namespace lambda {
Chris@16 53
Chris@16 54 #define BOOST_LAMBDA_IS_INSTANCE_OF_TEMPLATE(INDEX) \
Chris@16 55 \
Chris@16 56 namespace detail { \
Chris@16 57 \
Chris@16 58 template <template<BOOST_LAMBDA_CLASS_LIST(INDEX,T)> class F> \
Chris@16 59 struct BOOST_PP_CAT(conversion_tester_,INDEX) { \
Chris@16 60 template<BOOST_LAMBDA_CLASS_ARG_LIST(INDEX,A)> \
Chris@16 61 BOOST_PP_CAT(conversion_tester_,INDEX) \
Chris@16 62 (const F<BOOST_LAMBDA_ARG_LIST(INDEX,A)>&); \
Chris@16 63 }; \
Chris@16 64 \
Chris@16 65 } /* end detail */ \
Chris@16 66 \
Chris@16 67 template <class From, template <BOOST_LAMBDA_CLASS_LIST(INDEX,T)> class To> \
Chris@16 68 struct BOOST_PP_CAT(is_instance_of_,INDEX) \
Chris@16 69 { \
Chris@16 70 private: \
Chris@16 71 typedef ::boost::is_convertible< \
Chris@16 72 From, \
Chris@16 73 BOOST_PP_CAT(detail::conversion_tester_,INDEX)<To> \
Chris@16 74 > helper_type; \
Chris@16 75 \
Chris@16 76 public: \
Chris@16 77 BOOST_STATIC_CONSTANT(bool, value = helper_type::value); \
Chris@16 78 };
Chris@16 79
Chris@16 80
Chris@16 81 #define BOOST_LAMBDA_HELPER(z, N, A) BOOST_LAMBDA_IS_INSTANCE_OF_TEMPLATE( BOOST_PP_INC(N) )
Chris@16 82
Chris@16 83 // Generate the traits for 1-4 argument templates
Chris@16 84
Chris@16 85 BOOST_PP_REPEAT_2ND(4,BOOST_LAMBDA_HELPER,FOO)
Chris@16 86
Chris@16 87 #undef BOOST_LAMBDA_HELPER
Chris@16 88 #undef BOOST_LAMBDA_IS_INSTANCE_OF_TEMPLATE
Chris@16 89 #undef BOOST_LAMBDA_CLASS
Chris@16 90 #undef BOOST_LAMBDA_ARG
Chris@16 91 #undef BOOST_LAMBDA_CLASS_ARG
Chris@16 92 #undef BOOST_LAMBDA_CLASS_LIST
Chris@16 93 #undef BOOST_LAMBDA_ARG_LIST
Chris@16 94 #undef BOOST_LAMBDA_CLASS_ARG_LIST
Chris@16 95
Chris@16 96 } // lambda
Chris@16 97 } // boost
Chris@16 98
Chris@16 99 #endif
Chris@16 100
Chris@16 101
Chris@16 102
Chris@16 103
Chris@16 104