2 Changes made while bringing boost/concept_check.hpp to v3's concept_check.h:
4 1) File format changed from DOS to Unix.
5 2) Boost config.hpp and other workaround files dropped (unneeded in g++ v3).
6 3) Conditionally-compiled code depending on those "breakage" macros was
7 removed, or not, depending on the macro, so that the macros themselves
8 are gone. Since the same code would always be compiled, let's make it
9 easier on the reader and a few milliseconds faster for cpplib.
10 4) Tests for NDEBUG were removed; if NDEBUG is defined, none of the checking
11 code will even be included.
12 5) BOOST_CLASS_REQUIRES* changed to accept a namespace parameter.
13 6) SameTypeConcept added (simple wrapper around existing code).
14 7) An unused variable in OutputIteratorConcept was removed.
16 At checkin, this was the exact diff, modulo the end-of-line character changes:
19 --- concept_check.hpp.orig Sun Apr 1 08:59:46 2001
20 +++ boost_concept_check.h Mon Apr 2 18:56:41 2001
22 // "as is" without express or implied warranty, and with no claim as
23 // to its suitability for any purpose.
26 +// GCC Note: based on version 1.12.0 of the Boost library.
27 #ifndef BOOST_CONCEPT_CHECKS_HPP
28 #define BOOST_CONCEPT_CHECKS_HPP
30 -#include <boost/config.hpp>
31 -#include <boost/iterator.hpp>
32 -#include <boost/iterator.hpp>
34 -#include <boost/pending/limits.hpp>
36 -#if (__GNUC__) || defined(__KCC) || defined(__ghs) || defined(__MWERKS__)
41 +#pragma GCC system_header
42 +#include <bits/stl_iterator_base_types.h> // for traits and tags
43 +#include <utility> // for pair<>
49 template <class Concept>
50 void function_requires()
53 - void (Concept::*x)() = BOOST_FPTR Concept::constraints;
54 + void (Concept::*x)() = &Concept::constraints;
55 ignore_unused_variable_warning(x);
59 -// The BOOST_CLASS_REQUIRES macros use function pointers as
60 -// template parameters, which VC++ does not support.
62 -#if defined(BOOST_NO_FUNCTION_PTR_TEMPLATE_PARAMETERS)
64 -#define BOOST_CLASS_REQUIRES(type_var, concept)
65 -#define BOOST_CLASS_REQUIRES2(type_var1, type_var2, concept)
66 -#define BOOST_CLASS_REQUIRES3(type_var1, type_var2, type_var3, concept)
67 -#define BOOST_CLASS_REQUIRES4(type_var1, type_var2, type_var3, type_var4, concept)
71 -#define BOOST_CLASS_REQUIRES(type_var, concept) \
72 - typedef void (concept <type_var>::* func##type_var##concept)(); \
73 +#define BOOST_CLASS_REQUIRES(type_var, ns, concept) \
74 + typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
75 template <func##type_var##concept _Tp1> \
76 struct concept_checking_##type_var##concept { }; \
77 typedef concept_checking_##type_var##concept< \
78 - BOOST_FPTR concept <type_var>::constraints> \
79 + &ns::concept <type_var>::constraints> \
80 concept_checking_typedef_##type_var##concept
82 -#define BOOST_CLASS_REQUIRES2(type_var1, type_var2, concept) \
83 - typedef void (concept <type_var1,type_var2>::* func##type_var1##type_var2##concept)(); \
84 +#define BOOST_CLASS_REQUIRES2(type_var1, type_var2, ns, concept) \
85 + typedef void (ns::concept <type_var1,type_var2>::* func##type_var1##type_var2##concept)(); \
86 template <func##type_var1##type_var2##concept _Tp1> \
87 struct concept_checking_##type_var1##type_var2##concept { }; \
88 typedef concept_checking_##type_var1##type_var2##concept< \
89 - BOOST_FPTR concept <type_var1,type_var2>::constraints> \
90 + &ns::concept <type_var1,type_var2>::constraints> \
91 concept_checking_typedef_##type_var1##type_var2##concept
93 -#define BOOST_CLASS_REQUIRES3(type_var1, type_var2, type_var3, concept) \
94 - typedef void (concept <type_var1,type_var2,type_var3>::* func##type_var1##type_var2##type_var3##concept)(); \
95 +#define BOOST_CLASS_REQUIRES3(type_var1, type_var2, type_var3, ns, concept) \
96 + typedef void (ns::concept <type_var1,type_var2,type_var3>::* func##type_var1##type_var2##type_var3##concept)(); \
97 template <func##type_var1##type_var2##type_var3##concept _Tp1> \
98 struct concept_checking_##type_var1##type_var2##type_var3##concept { }; \
99 typedef concept_checking_##type_var1##type_var2##type_var3##concept< \
100 - BOOST_FPTR concept <type_var1,type_var2,type_var3>::constraints> \
101 + &ns::concept <type_var1,type_var2,type_var3>::constraints> \
102 concept_checking_typedef_##type_var1##type_var2##type_var3##concept
104 -#define BOOST_CLASS_REQUIRES4(type_var1, type_var2, type_var3, type_var4, concept) \
105 - typedef void (concept <type_var1,type_var2,type_var3,type_var4>::* func##type_var1##type_var2##type_var3##type_var4##concept)(); \
106 +#define BOOST_CLASS_REQUIRES4(type_var1, type_var2, type_var3, type_var4, ns, concept) \
107 + typedef void (ns::concept <type_var1,type_var2,type_var3,type_var4>::* func##type_var1##type_var2##type_var3##type_var4##concept)(); \
108 template <func##type_var1##type_var2##type_var3##type_var4##concept _Tp1> \
109 struct concept_checking_##type_var1##type_var2##type_var3##type_var4##concept { }; \
110 typedef concept_checking_##type_var1##type_var2##type_var3##type_var4##concept< \
111 - BOOST_FPTR concept <type_var1,type_var2,type_var3,type_var4>::constraints> \
112 + &ns::concept <type_var1,type_var2,type_var3,type_var4>::constraints> \
113 concept_checking_typedef_##type_var1##type_var2##type_var3##type_var4##concept
118 -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
119 template <class T, class U>
120 struct require_same { };
123 struct require_same<T,T> { typedef T type; };
125 -// This version does not perform checking, but will not do any harm.
126 -template <class T, class U>
127 -struct require_same { typedef T type; };
130 + template <class T, class U>
131 + struct SameTypeConcept
133 + void constraints() {
134 + typedef typename require_same<T, U>::type req;
139 struct IntegerConcept {
141 -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
142 errortype_must_be_an_integer_type();
146 -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
147 template <> struct IntegerConcept<short> { void constraints() {} };
148 template <> struct IntegerConcept<unsigned short> { void constraints() {} };
149 template <> struct IntegerConcept<int> { void constraints() {} };
151 template <> struct IntegerConcept<long> { void constraints() {} };
152 template <> struct IntegerConcept<unsigned long> { void constraints() {} };
157 struct SignedIntegerConcept {
159 -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
160 errortype_must_be_a_signed_integer_type();
164 -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
165 template <> struct SignedIntegerConcept<short> { void constraints() {} };
166 template <> struct SignedIntegerConcept<int> { void constraints() {} };
167 template <> struct SignedIntegerConcept<long> { void constraints() {} };
172 struct UnsignedIntegerConcept {
174 -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
175 errortype_must_be_an_unsigned_integer_type();
179 -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
180 template <> struct UnsignedIntegerConcept<unsigned short>
181 { void constraints() {} };
182 template <> struct UnsignedIntegerConcept<unsigned int>
184 template <> struct UnsignedIntegerConcept<unsigned long>
185 { void constraints() {} };
189 //===========================================================================
191 @@ -159,15 +129,11 @@
192 struct AssignableConcept
195 -#if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL
196 a = a; // require assignment operator
198 const_constraints(a);
200 void const_constraints(const TT& b) {
201 -#if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL
202 a = b; // const required for argument to assignment
207 @@ -196,17 +162,13 @@
211 -#if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL
212 a = a; // require assignment operator
214 const_constraints(a);
215 ignore_unused_variable_warning(b);
217 void const_constraints(const TT& b) {
219 -#if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL
220 a = b; // const required for argument to assignment
222 ignore_unused_variable_warning(c);
226 BOOST_DEFINE_BINARY_OPERATOR_CONSTRAINT(-, SubtractOpConcept);
227 BOOST_DEFINE_BINARY_OPERATOR_CONSTRAINT(%, ModOpConcept);
229 +#undef BOOST_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT
230 +#undef BOOST_DEFINE_BINARY_OPERATOR_CONSTRAINT
232 //===========================================================================
233 // Function Object Concepts
239 -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
240 template <class Func>
241 struct GeneratorConcept<Func,void>
249 template <class Func, class Return, class Arg>
250 struct UnaryFunctionConcept
255 -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
256 template <class Func, class Arg>
257 struct UnaryFunctionConcept<Func, void, Arg> {
265 template <class Func, class Return, class First, class Second>
266 struct BinaryFunctionConcept
271 -#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
272 template <class Func, class First, class Second>
273 struct BinaryFunctionConcept<Func, void, First, Second>
281 template <class Func, class Arg>
282 struct UnaryPredicateConcept
284 function_requires< AssignableConcept<TT> >();
285 function_requires< DefaultConstructibleConcept<TT> >();
286 function_requires< EqualityComparableConcept<TT> >();
287 -#ifndef BOOST_NO_STD_ITERATOR_TRAITS
288 typedef typename std::iterator_traits<TT>::value_type V;
290 (void)*i; // require dereference operator
295 function_requires< TrivialIteratorConcept<TT> >();
296 // require iterator_traits typedef's
297 -#ifndef BOOST_NO_STD_ITERATOR_TRAITS
298 typedef typename std::iterator_traits<TT>::difference_type D;
299 function_requires< SignedIntegerConcept<D> >();
300 typedef typename std::iterator_traits<TT>::reference R;
302 function_requires< ConvertibleConcept<
303 typename std::iterator_traits<TT>::iterator_category,
304 std::input_iterator_tag> >();
306 ++i; // require preincrement operator
307 i++; // require postincrement operator
310 i++; // require postincrement operator
311 *i++ = t; // require postincrement and assignment
318 @@ -480,14 +435,12 @@
321 function_requires< InputIteratorConcept<TT> >();
322 -#ifndef BOOST_NO_STD_ITERATOR_TRAITS
323 function_requires< ConvertibleConcept<
324 typename std::iterator_traits<TT>::iterator_category,
325 std::forward_iterator_tag> >();
326 typedef typename std::iterator_traits<TT>::reference reference;
328 ignore_unused_variable_warning(r);
336 function_requires< ForwardIteratorConcept<TT> >();
337 -#ifndef BOOST_NO_STD_ITERATOR_TRAITS
338 function_requires< ConvertibleConcept<
339 typename std::iterator_traits<TT>::iterator_category,
340 std::bidirectional_iterator_tag> >();
342 --i; // require predecrement operator
343 i--; // require postdecrement operator
345 @@ -536,12 +487,10 @@
347 function_requires< BidirectionalIteratorConcept<TT> >();
348 function_requires< ComparableConcept<TT> >();
349 -#ifndef BOOST_NO_STD_ITERATOR_TRAITS
350 function_requires< ConvertibleConcept<
351 typename std::iterator_traits<TT>::iterator_category,
352 std::random_access_iterator_tag> >();
353 typedef typename std::iterator_traits<TT>::reference R;
356 i += n; // require assignment addition operator
357 i = i + n; i = n + i; // require addition with difference type
362 -#ifndef BOOST_NO_STD_ITERATOR_TRAITS
363 typename std::iterator_traits<TT>::difference_type n;
371 i[n] = *i; // require element access and assignment
374 -#ifndef BOOST_NO_STD_ITERATOR_TRAITS
375 typename std::iterator_traits<TT>::difference_type n;
381 //===========================================================================