imgtools/imglib/boostlibrary/boost/concept/requires.hpp
changeset 2 39c28ec933dd
equal deleted inserted replaced
1:820b22e13ff1 2:39c28ec933dd
       
     1 // Copyright David Abrahams 2006. Distributed under the Boost
       
     2 // Software License, Version 1.0. (See accompanying
       
     3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       
     4 #ifndef BOOST_CONCEPT_REQUIRES_DWA2006430_HPP
       
     5 # define BOOST_CONCEPT_REQUIRES_DWA2006430_HPP
       
     6 
       
     7 # include <boost/config.hpp>
       
     8 # include <boost/parameter/aux_/parenthesized_type.hpp>
       
     9 # include <boost/concept/assert.hpp>
       
    10 # include <boost/preprocessor/seq/for_each.hpp>
       
    11 
       
    12 namespace boost { 
       
    13 
       
    14 // Template for use in handwritten assertions
       
    15 template <class Model, class More>
       
    16 struct requires_ : More
       
    17 {
       
    18 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
       
    19     typedef typename More::type type;
       
    20 # endif 
       
    21     BOOST_CONCEPT_ASSERT((Model));
       
    22 };
       
    23 
       
    24 // Template for use by macros, where models must be wrapped in parens.
       
    25 // This isn't in namespace detail to keep extra cruft out of resulting
       
    26 // error messages.
       
    27 template <class ModelFn>
       
    28 struct _requires_
       
    29 {
       
    30     enum { value = 0 };
       
    31     BOOST_CONCEPT_ASSERT_FN(ModelFn);
       
    32 };
       
    33 
       
    34 template <int check, class Result>
       
    35 struct Requires_ : ::boost::parameter::aux::unaryfunptr_arg_type<Result>
       
    36 {
       
    37 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
       
    38     typedef typename ::boost::parameter::aux::unaryfunptr_arg_type<Result>::type type;
       
    39 # endif 
       
    40 };
       
    41 
       
    42 # if BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(1010))
       
    43 #  define BOOST_CONCEPT_REQUIRES_(r,data,t) | (::boost::_requires_<void(*)t>::value)
       
    44 # else 
       
    45 #  define BOOST_CONCEPT_REQUIRES_(r,data,t) + (::boost::_requires_<void(*)t>::value)
       
    46 # endif
       
    47 
       
    48 #if defined(NDEBUG) || BOOST_WORKAROUND(BOOST_MSVC, < 1300)
       
    49 
       
    50 # define BOOST_CONCEPT_REQUIRES(models, result)                                    \
       
    51     typename ::boost::parameter::aux::unaryfunptr_arg_type<void(*)result>::type
       
    52 
       
    53 #elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
       
    54 
       
    55 // Same thing as below without the initial typename
       
    56 # define BOOST_CONCEPT_REQUIRES(models, result)                                \
       
    57     ::boost::Requires_<                                                        \
       
    58       (0 BOOST_PP_SEQ_FOR_EACH(BOOST_CONCEPT_REQUIRES_, ~, models)),           \
       
    59       ::boost::parameter::aux::unaryfunptr_arg_type<void(*)result>          \
       
    60                      >::type
       
    61 
       
    62 #else
       
    63 
       
    64 // This just ICEs on MSVC6 :(
       
    65 # define BOOST_CONCEPT_REQUIRES(models, result)                                        \
       
    66     typename ::boost::Requires_<                                                       \
       
    67       (0 BOOST_PP_SEQ_FOR_EACH(BOOST_CONCEPT_REQUIRES_, ~, models)),                   \
       
    68       void(*)result                                                                 \
       
    69     >::type
       
    70 
       
    71 #endif 
       
    72 
       
    73 // C++0x proposed syntax changed.  This supports an older usage
       
    74 #define BOOST_CONCEPT_WHERE(models,result) BOOST_CONCEPT_REQUIRES(models,result)
       
    75 
       
    76 } // namespace boost::concept_check
       
    77 
       
    78 #endif // BOOST_CONCEPT_REQUIRES_DWA2006430_HPP