From d9cb7a1e91b72c01dfc2183340f9fa06d2284ef0 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Tue, 3 Oct 2000 22:15:02 +0000 Subject: [PATCH] added Boolean_concept to concept checks to tighten up LessThanComparable (thanks to Brian McNamara and Yassin Smaragdakis for catching this!) [SVN r7902] --- include/boost/pending/concept_checks.hpp | 29 ++++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/include/boost/pending/concept_checks.hpp b/include/boost/pending/concept_checks.hpp index 3ac7ec4..57c8a9c 100644 --- a/include/boost/pending/concept_checks.hpp +++ b/include/boost/pending/concept_checks.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #if defined(__GNUC__) || defined(__KCC) || defined(__ghs) #define BOOST_FPTR & @@ -190,13 +191,27 @@ template void ignore_unused_variable_warning(const T&) { } T b; }; + template + struct Boolean_concept { + void constraints() { + b = x; + b = x || x; + b = x && x; + } + TT x; + bool b; + }; + template struct EqualityComparable_concept { void constraints() { - r = a == b; // require equality operator - r = a != b; // require inequality operator + require_boolean_return(a == b); + require_boolean_return(a != b); } + // Can't move the following outside, because it changes when + // the error message appears. + template void require_boolean_return(B) { REQUIRE(B, Boolean); } TT a, b; bool r; }; @@ -205,11 +220,15 @@ template void ignore_unused_variable_warning(const T&) { } struct LessThanComparable_concept { void constraints() { - // require comparison operators - r = a < b || a > b || a <= b || a >= b; + require_boolean_return(a < b); + require_boolean_return(a > b); + require_boolean_return(a <= b); + require_boolean_return(a >= b); } + // Can't move the following outside, because it changes when + // the error message appears. + template void require_boolean_return(B) { REQUIRE(B, Boolean); } TT a, b; - bool r; }; //===========================================================================