1 // Copyright Jeremy Siek, David Abrahams 2000-2006. Distributed under 2 // the Boost Software License, Version 1.0. (See accompanying file 3 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 #ifndef BOOST_LIBS_CONCEPT_CHECK_OLD_CONCEPTS_DWA2006428_HPP 5 # define BOOST_LIBS_CONCEPT_CHECK_OLD_CONCEPTS_DWA2006428_HPP 6 7 #include <boost/concept_check.hpp> 8 9 namespace old 10 { 11 template <class TT> require_boolean_expr(const TT & t)12 void require_boolean_expr(const TT& t) { 13 bool x = t; 14 boost::ignore_unused_variable_warning(x); 15 } 16 17 template <class TT> 18 struct EqualityComparableConcept 19 { constraintsold::EqualityComparableConcept20 void constraints() { 21 boost::require_boolean_expr(a == b); 22 boost::require_boolean_expr(a != b); 23 } 24 TT a, b; 25 }; 26 27 template <class Func, class Return, class Arg> 28 struct UnaryFunctionConcept 29 { 30 // required in case any of our template args are const-qualified: 31 UnaryFunctionConcept(); 32 constraintsold::UnaryFunctionConcept33 void constraints() { 34 r = f(arg); // require operator() 35 } 36 Func f; 37 Arg arg; 38 Return r; 39 }; 40 41 template <class Func, class Return, class First, class Second> 42 struct BinaryFunctionConcept 43 { constraintsold::BinaryFunctionConcept44 void constraints() { 45 r = f(first, second); // require operator() 46 } 47 Func f; 48 First first; 49 Second second; 50 Return r; 51 }; 52 53 #define DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(OP,NAME) \ 54 template <class First, class Second> \ 55 struct NAME { \ 56 void constraints() { (void)constraints_(); } \ 57 bool constraints_() { \ 58 return a OP b; \ 59 } \ 60 First a; \ 61 Second b; \ 62 } 63 64 DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(==, EqualOpConcept); 65 } 66 67 #endif // BOOST_LIBS_CONCEPT_CHECK_OLD_CONCEPTS_DWA2006428_HPP 68