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
7 # include <boost/config.hpp>
8 # include <boost/concept/assert.hpp>
9 # include <boost/preprocessor/seq/for_each.hpp>
13 // unaryfunptr_arg_type from parameter/aux_/parenthesized_type.hpp
15 namespace ccheck_aux {
17 // A metafunction that transforms void(*)(T) -> T
18 template <class UnaryFunctionPointer>
19 struct unaryfunptr_arg_type;
22 struct unaryfunptr_arg_type<void(*)(Arg)>
28 struct unaryfunptr_arg_type<void(*)(void)>
33 } // namespace ccheck_aux
35 // Template for use in handwritten assertions
36 template <class Model, class More>
37 struct requires_ : More
39 BOOST_CONCEPT_ASSERT((Model));
42 // Template for use by macros, where models must be wrapped in parens.
43 // This isn't in namespace detail to keep extra cruft out of resulting
45 template <class ModelFn>
49 BOOST_CONCEPT_ASSERT_FN(ModelFn);
52 template <int check, class Result>
53 struct Requires_ : ::boost::ccheck_aux::unaryfunptr_arg_type<Result>
57 # if BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(1010))
58 # define BOOST_CONCEPT_REQUIRES_(r,data,t) | (::boost::_requires_<void(*)t>::value)
60 # define BOOST_CONCEPT_REQUIRES_(r,data,t) + (::boost::_requires_<void(*)t>::value)
65 # define BOOST_CONCEPT_REQUIRES(models, result) \
66 typename ::boost::ccheck_aux::unaryfunptr_arg_type<void(*)result>::type
68 #elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
70 // Same thing as below without the initial typename
71 # define BOOST_CONCEPT_REQUIRES(models, result) \
73 (0 BOOST_PP_SEQ_FOR_EACH(BOOST_CONCEPT_REQUIRES_, ~, models)), \
74 ::boost::ccheck_aux::unaryfunptr_arg_type<void(*)result> \
79 // This just ICEs on MSVC6 :(
80 # define BOOST_CONCEPT_REQUIRES(models, result) \
81 typename ::boost::Requires_< \
82 (0 BOOST_PP_SEQ_FOR_EACH(BOOST_CONCEPT_REQUIRES_, ~, models)), \
88 // C++0x proposed syntax changed. This supports an older usage
89 #define BOOST_CONCEPT_WHERE(models,result) BOOST_CONCEPT_REQUIRES(models,result)
91 } // namespace boost::concept_check
93 #endif // BOOST_CONCEPT_REQUIRES_DWA2006430_HPP