Chris@16
|
1 // Copyright David Abrahams 2006. Distributed under the Boost
|
Chris@16
|
2 // Software License, Version 1.0. (See accompanying
|
Chris@16
|
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
4 #ifndef BOOST_CONCEPT_DETAIL_HAS_CONSTRAINTS_DWA2006429_HPP
|
Chris@16
|
5 # define BOOST_CONCEPT_DETAIL_HAS_CONSTRAINTS_DWA2006429_HPP
|
Chris@16
|
6
|
Chris@16
|
7 # include <boost/mpl/bool.hpp>
|
Chris@16
|
8 # include <boost/detail/workaround.hpp>
|
Chris@16
|
9 # include <boost/concept/detail/backward_compatibility.hpp>
|
Chris@16
|
10
|
Chris@16
|
11 namespace boost { namespace concepts {
|
Chris@16
|
12
|
Chris@16
|
13 namespace detail
|
Chris@16
|
14 {
|
Chris@16
|
15
|
Chris@16
|
16 // Here we implement the metafunction that detects whether a
|
Chris@16
|
17 // constraints metafunction exists
|
Chris@16
|
18 typedef char yes;
|
Chris@16
|
19 typedef char (&no)[2];
|
Chris@16
|
20
|
Chris@16
|
21 template <class Model, void (Model::*)()>
|
Chris@16
|
22 struct wrap_constraints {};
|
Chris@16
|
23
|
Chris@16
|
24 #if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x580) || defined(__CUDACC__)
|
Chris@16
|
25 // Work around the following bogus error in Sun Studio 11, by
|
Chris@16
|
26 // turning off the has_constraints function entirely:
|
Chris@16
|
27 // Error: complex expression not allowed in dependent template
|
Chris@16
|
28 // argument expression
|
Chris@16
|
29 inline no has_constraints_(...);
|
Chris@16
|
30 #else
|
Chris@16
|
31 template <class Model>
|
Chris@16
|
32 inline yes has_constraints_(Model*, wrap_constraints<Model,&Model::constraints>* = 0);
|
Chris@16
|
33 inline no has_constraints_(...);
|
Chris@16
|
34 #endif
|
Chris@16
|
35 }
|
Chris@16
|
36
|
Chris@16
|
37 // This would be called "detail::has_constraints," but it has a strong
|
Chris@16
|
38 // tendency to show up in error messages.
|
Chris@16
|
39 template <class Model>
|
Chris@16
|
40 struct not_satisfied
|
Chris@16
|
41 {
|
Chris@16
|
42 BOOST_STATIC_CONSTANT(
|
Chris@16
|
43 bool
|
Chris@16
|
44 , value = sizeof( detail::has_constraints_((Model*)0) ) == sizeof(detail::yes) );
|
Chris@16
|
45 typedef mpl::bool_<value> type;
|
Chris@16
|
46 };
|
Chris@16
|
47
|
Chris@16
|
48 }} // namespace boost::concepts::detail
|
Chris@16
|
49
|
Chris@16
|
50 #endif // BOOST_CONCEPT_DETAIL_HAS_CONSTRAINTS_DWA2006429_HPP
|