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/concept/assert.hpp>
9# include <boost/preprocessor/seq/for_each.hpp>
10
11namespace boost {
12
13// unaryfunptr_arg_type from parameter/aux_/parenthesized_type.hpp
14
15namespace ccheck_aux {
16
17// A metafunction that transforms void(*)(T) -> T
18template <class UnaryFunctionPointer>
19struct unaryfunptr_arg_type;
20
21template <class Arg>
22struct unaryfunptr_arg_type<void(*)(Arg)>
23{
24 typedef Arg type;
25};
26
27template <>
28struct unaryfunptr_arg_type<void(*)(void)>
29{
30 typedef void type;
31};
32
33} // namespace ccheck_aux
34
35// Template for use in handwritten assertions
36template <class Model, class More>
37struct requires_ : More
38{
39 BOOST_CONCEPT_ASSERT((Model));
40};
41
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
44// error messages.
45template <class ModelFn>
46struct _requires_
47{
48 enum { value = 0 };
49 BOOST_CONCEPT_ASSERT_FN(ModelFn);
50};
51
52template <int check, class Result>
53struct Requires_ : ::boost::ccheck_aux::unaryfunptr_arg_type<Result>
54{
55};
56
57# if BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(1010))
58# define BOOST_CONCEPT_REQUIRES_(r,data,t) | (::boost::_requires_<void(*)t>::value)
59# else
60# define BOOST_CONCEPT_REQUIRES_(r,data,t) + (::boost::_requires_<void(*)t>::value)
61# endif
62
63#if defined(NDEBUG)
64
65# define BOOST_CONCEPT_REQUIRES(models, result) \
66 typename ::boost::ccheck_aux::unaryfunptr_arg_type<void(*)result>::type
67
68#elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
69
70// Same thing as below without the initial typename
71# define BOOST_CONCEPT_REQUIRES(models, result) \
72 ::boost::Requires_< \
73 (0 BOOST_PP_SEQ_FOR_EACH(BOOST_CONCEPT_REQUIRES_, ~, models)), \
74 ::boost::ccheck_aux::unaryfunptr_arg_type<void(*)result> \
75 >::type
76
77#else
78
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)), \
83 void(*)result \
84 >::type
85
86#endif
87
88// C++0x proposed syntax changed. This supports an older usage
89#define BOOST_CONCEPT_WHERE(models,result) BOOST_CONCEPT_REQUIRES(models,result)
90
91} // namespace boost::concept_check
92
93#endif // BOOST_CONCEPT_REQUIRES_DWA2006430_HPP
94

source code of boost/boost/concept/requires.hpp