fix doc example typo
[boost.git] / boost / concept / requires.hpp
blob024ba742c9c96bd0dae3e83a5754de36d13910f3
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/parameter/aux_/parenthesized_type.hpp>
9 # include <boost/concept/assert.hpp>
10 # include <boost/preprocessor/seq/for_each.hpp>
12 namespace boost {
14 // Template for use in handwritten assertions
15 template <class Model, class More>
16 struct requires_ : More
18 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
19 typedef typename More::type type;
20 # endif
21 BOOST_CONCEPT_ASSERT((Model));
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_
30 enum { value = 0 };
31 BOOST_CONCEPT_ASSERT_FN(ModelFn);
34 template <int check, class Result>
35 struct Requires_ : ::boost::parameter::aux::unaryfunptr_arg_type<Result>
37 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
38 typedef typename ::boost::parameter::aux::unaryfunptr_arg_type<Result>::type type;
39 # endif
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
48 #if defined(NDEBUG) || BOOST_WORKAROUND(BOOST_MSVC, < 1300)
50 # define BOOST_CONCEPT_REQUIRES(models, result) \
51 typename ::boost::parameter::aux::unaryfunptr_arg_type<void(*)result>::type
53 #elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
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
62 #else
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
71 #endif
73 // C++0x proposed syntax changed. This supports an older usage
74 #define BOOST_CONCEPT_WHERE(models,result) BOOST_CONCEPT_REQUIRES(models,result)
76 } // namespace boost::concept_check
78 #endif // BOOST_CONCEPT_REQUIRES_DWA2006430_HPP