Changes made while bringing boost/concept_check.hpp to v3's concept_check.h: 1) File format changed from DOS to Unix. 2) Boost config.hpp and other workaround files dropped (unneeded in g++ v3). 3) Conditionally-compiled code depending on those "breakage" macros was removed, or not, depending on the macro, so that the macros themselves are gone. Since the same code would always be compiled, let's make it easier on the reader and a few milliseconds faster for cpplib. 4) Tests for NDEBUG were removed; if NDEBUG is defined, none of the checking code will even be included. 5) BOOST_CLASS_REQUIRES* changed to accept a namespace parameter. 6) SameTypeConcept added (simple wrapper around existing code). 7) An unused variable in OutputIteratorConcept was removed. At checkin, this was the exact diff, modulo the end-of-line character changes: --- concept_check.hpp.orig Sun Apr 1 08:59:46 2001 +++ boost_concept_check.h Mon Apr 2 18:56:41 2001 @@ -5,20 +5,15 @@ // "as is" without express or implied warranty, and with no claim as // to its suitability for any purpose. // + +// GCC Note: based on version 1.12.0 of the Boost library. #ifndef BOOST_CONCEPT_CHECKS_HPP #define BOOST_CONCEPT_CHECKS_HPP -#include -#include -#include -#include -#include - -#if (__GNUC__) || defined(__KCC) || defined(__ghs) || defined(__MWERKS__) -#define BOOST_FPTR & -#else -#define BOOST_FPTR -#endif +#pragma GCC system_header +#include // for traits and tags +#include // for pair<> + namespace boost { @@ -27,80 +22,64 @@ template void function_requires() { -#if !defined(NDEBUG) - void (Concept::*x)() = BOOST_FPTR Concept::constraints; + void (Concept::*x)() = &Concept::constraints; ignore_unused_variable_warning(x); -#endif } -// The BOOST_CLASS_REQUIRES macros use function pointers as -// template parameters, which VC++ does not support. - -#if defined(BOOST_NO_FUNCTION_PTR_TEMPLATE_PARAMETERS) - -#define BOOST_CLASS_REQUIRES(type_var, concept) -#define BOOST_CLASS_REQUIRES2(type_var1, type_var2, concept) -#define BOOST_CLASS_REQUIRES3(type_var1, type_var2, type_var3, concept) -#define BOOST_CLASS_REQUIRES4(type_var1, type_var2, type_var3, type_var4, concept) -#else - -#define BOOST_CLASS_REQUIRES(type_var, concept) \ - typedef void (concept ::* func##type_var##concept)(); \ +#define BOOST_CLASS_REQUIRES(type_var, ns, concept) \ + typedef void (ns::concept ::* func##type_var##concept)(); \ template \ struct concept_checking_##type_var##concept { }; \ typedef concept_checking_##type_var##concept< \ - BOOST_FPTR concept ::constraints> \ + &ns::concept ::constraints> \ concept_checking_typedef_##type_var##concept -#define BOOST_CLASS_REQUIRES2(type_var1, type_var2, concept) \ - typedef void (concept ::* func##type_var1##type_var2##concept)(); \ +#define BOOST_CLASS_REQUIRES2(type_var1, type_var2, ns, concept) \ + typedef void (ns::concept ::* func##type_var1##type_var2##concept)(); \ template \ struct concept_checking_##type_var1##type_var2##concept { }; \ typedef concept_checking_##type_var1##type_var2##concept< \ - BOOST_FPTR concept ::constraints> \ + &ns::concept ::constraints> \ concept_checking_typedef_##type_var1##type_var2##concept -#define BOOST_CLASS_REQUIRES3(type_var1, type_var2, type_var3, concept) \ - typedef void (concept ::* func##type_var1##type_var2##type_var3##concept)(); \ +#define BOOST_CLASS_REQUIRES3(type_var1, type_var2, type_var3, ns, concept) \ + typedef void (ns::concept ::* func##type_var1##type_var2##type_var3##concept)(); \ template \ struct concept_checking_##type_var1##type_var2##type_var3##concept { }; \ typedef concept_checking_##type_var1##type_var2##type_var3##concept< \ - BOOST_FPTR concept ::constraints> \ + &ns::concept ::constraints> \ concept_checking_typedef_##type_var1##type_var2##type_var3##concept -#define BOOST_CLASS_REQUIRES4(type_var1, type_var2, type_var3, type_var4, concept) \ - typedef void (concept ::* func##type_var1##type_var2##type_var3##type_var4##concept)(); \ +#define BOOST_CLASS_REQUIRES4(type_var1, type_var2, type_var3, type_var4, ns, concept) \ + typedef void (ns::concept ::* func##type_var1##type_var2##type_var3##type_var4##concept)(); \ template \ struct concept_checking_##type_var1##type_var2##type_var3##type_var4##concept { }; \ typedef concept_checking_##type_var1##type_var2##type_var3##type_var4##concept< \ - BOOST_FPTR concept ::constraints> \ + &ns::concept ::constraints> \ concept_checking_typedef_##type_var1##type_var2##type_var3##type_var4##concept -#endif - -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template struct require_same { }; template struct require_same { typedef T type; }; -#else -// This version does not perform checking, but will not do any harm. -template -struct require_same { typedef T type; }; -#endif + + template + struct SameTypeConcept + { + void constraints() { + typedef typename require_same::type req; + } + }; template struct IntegerConcept { void constraints() { -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION errortype_must_be_an_integer_type(); -#endif } }; -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template <> struct IntegerConcept { void constraints() {} }; template <> struct IntegerConcept { void constraints() {} }; template <> struct IntegerConcept { void constraints() {} }; @@ -108,32 +87,24 @@ template <> struct IntegerConcept { void constraints() {} }; template <> struct IntegerConcept { void constraints() {} }; // etc. -#endif template struct SignedIntegerConcept { void constraints() { -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION errortype_must_be_a_signed_integer_type(); -#endif } }; -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template <> struct SignedIntegerConcept { void constraints() {} }; template <> struct SignedIntegerConcept { void constraints() {} }; template <> struct SignedIntegerConcept { void constraints() {} }; // etc. -#endif template struct UnsignedIntegerConcept { void constraints() { -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION errortype_must_be_an_unsigned_integer_type(); -#endif } }; -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template <> struct UnsignedIntegerConcept { void constraints() {} }; template <> struct UnsignedIntegerConcept @@ -141,7 +112,6 @@ template <> struct UnsignedIntegerConcept { void constraints() {} }; // etc. -#endif //=========================================================================== // Basic Concepts @@ -159,15 +129,11 @@ struct AssignableConcept { void constraints() { -#if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL a = a; // require assignment operator -#endif const_constraints(a); } void const_constraints(const TT& b) { -#if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL a = b; // const required for argument to assignment -#endif } TT a; }; @@ -196,17 +162,13 @@ { void constraints() { TT b(a); -#if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL a = a; // require assignment operator -#endif const_constraints(a); ignore_unused_variable_warning(b); } void const_constraints(const TT& b) { TT c(b); -#if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL a = b; // const required for argument to assignment -#endif ignore_unused_variable_warning(c); } TT a; @@ -304,6 +266,9 @@ BOOST_DEFINE_BINARY_OPERATOR_CONSTRAINT(-, SubtractOpConcept); BOOST_DEFINE_BINARY_OPERATOR_CONSTRAINT(%, ModOpConcept); +#undef BOOST_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT +#undef BOOST_DEFINE_BINARY_OPERATOR_CONSTRAINT + //=========================================================================== // Function Object Concepts @@ -318,7 +283,6 @@ }; -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template struct GeneratorConcept { @@ -327,7 +291,6 @@ } Func f; }; -#endif template struct UnaryFunctionConcept @@ -340,7 +303,6 @@ Return r; }; -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template struct UnaryFunctionConcept { void constraints() { @@ -348,7 +310,6 @@ } Func f; }; -#endif template struct BinaryFunctionConcept @@ -362,7 +323,6 @@ Return r; }; -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template struct BinaryFunctionConcept { @@ -373,7 +333,6 @@ First first; Second second; }; -#endif template struct UnaryPredicateConcept @@ -422,9 +381,7 @@ function_requires< AssignableConcept >(); function_requires< DefaultConstructibleConcept >(); function_requires< EqualityComparableConcept >(); -#ifndef BOOST_NO_STD_ITERATOR_TRAITS typedef typename std::iterator_traits::value_type V; -#endif (void)*i; // require dereference operator } TT i; @@ -446,7 +403,6 @@ void constraints() { function_requires< TrivialIteratorConcept >(); // require iterator_traits typedef's -#ifndef BOOST_NO_STD_ITERATOR_TRAITS typedef typename std::iterator_traits::difference_type D; function_requires< SignedIntegerConcept >(); typedef typename std::iterator_traits::reference R; @@ -455,7 +411,6 @@ function_requires< ConvertibleConcept< typename std::iterator_traits::iterator_category, std::input_iterator_tag> >(); -#endif ++i; // require preincrement operator i++; // require postincrement operator } @@ -471,7 +426,7 @@ i++; // require postincrement operator *i++ = t; // require postincrement and assignment } - TT i, j; + TT i; ValueT t; }; @@ -480,14 +435,12 @@ { void constraints() { function_requires< InputIteratorConcept >(); -#ifndef BOOST_NO_STD_ITERATOR_TRAITS function_requires< ConvertibleConcept< typename std::iterator_traits::iterator_category, std::forward_iterator_tag> >(); typedef typename std::iterator_traits::reference reference; reference r = *i; ignore_unused_variable_warning(r); -#endif } TT i; }; @@ -507,11 +460,9 @@ { void constraints() { function_requires< ForwardIteratorConcept >(); -#ifndef BOOST_NO_STD_ITERATOR_TRAITS function_requires< ConvertibleConcept< typename std::iterator_traits::iterator_category, std::bidirectional_iterator_tag> >(); -#endif --i; // require predecrement operator i--; // require postdecrement operator } @@ -536,12 +487,10 @@ void constraints() { function_requires< BidirectionalIteratorConcept >(); function_requires< ComparableConcept >(); -#ifndef BOOST_NO_STD_ITERATOR_TRAITS function_requires< ConvertibleConcept< typename std::iterator_traits::iterator_category, std::random_access_iterator_tag> >(); typedef typename std::iterator_traits::reference R; -#endif i += n; // require assignment addition operator i = i + n; i = n + i; // require addition with difference type @@ -552,11 +501,7 @@ } TT a, b; TT i, j; -#ifndef BOOST_NO_STD_ITERATOR_TRAITS typename std::iterator_traits::difference_type n; -#else - std::ptrdiff_t n; -#endif }; template @@ -568,11 +513,7 @@ i[n] = *i; // require element access and assignment } TT i; -#ifndef BOOST_NO_STD_ITERATOR_TRAITS typename std::iterator_traits::difference_type n; -#else - std::ptrdiff_t n; -#endif }; //===========================================================================