1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
|
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 <boost/config.hpp>
-#include <boost/iterator.hpp>
-#include <boost/iterator.hpp>
-#include <utility>
-#include <boost/pending/limits.hpp>
-
-#if (__GNUC__) || defined(__KCC) || defined(__ghs) || defined(__MWERKS__)
-#define BOOST_FPTR &
-#else
-#define BOOST_FPTR
-#endif
+#pragma GCC system_header
+#include <bits/stl_iterator_base_types.h> // for traits and tags
+#include <utility> // for pair<>
+
namespace boost {
@@ -27,80 +22,64 @@
template <class Concept>
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 <type_var>::* func##type_var##concept)(); \
+#define BOOST_CLASS_REQUIRES(type_var, ns, concept) \
+ typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
template <func##type_var##concept _Tp1> \
struct concept_checking_##type_var##concept { }; \
typedef concept_checking_##type_var##concept< \
- BOOST_FPTR concept <type_var>::constraints> \
+ &ns::concept <type_var>::constraints> \
concept_checking_typedef_##type_var##concept
-#define BOOST_CLASS_REQUIRES2(type_var1, type_var2, concept) \
- typedef void (concept <type_var1,type_var2>::* func##type_var1##type_var2##concept)(); \
+#define BOOST_CLASS_REQUIRES2(type_var1, type_var2, ns, concept) \
+ typedef void (ns::concept <type_var1,type_var2>::* func##type_var1##type_var2##concept)(); \
template <func##type_var1##type_var2##concept _Tp1> \
struct concept_checking_##type_var1##type_var2##concept { }; \
typedef concept_checking_##type_var1##type_var2##concept< \
- BOOST_FPTR concept <type_var1,type_var2>::constraints> \
+ &ns::concept <type_var1,type_var2>::constraints> \
concept_checking_typedef_##type_var1##type_var2##concept
-#define BOOST_CLASS_REQUIRES3(type_var1, type_var2, type_var3, concept) \
- typedef void (concept <type_var1,type_var2,type_var3>::* func##type_var1##type_var2##type_var3##concept)(); \
+#define BOOST_CLASS_REQUIRES3(type_var1, type_var2, type_var3, ns, concept) \
+ typedef void (ns::concept <type_var1,type_var2,type_var3>::* func##type_var1##type_var2##type_var3##concept)(); \
template <func##type_var1##type_var2##type_var3##concept _Tp1> \
struct concept_checking_##type_var1##type_var2##type_var3##concept { }; \
typedef concept_checking_##type_var1##type_var2##type_var3##concept< \
- BOOST_FPTR concept <type_var1,type_var2,type_var3>::constraints> \
+ &ns::concept <type_var1,type_var2,type_var3>::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 <type_var1,type_var2,type_var3,type_var4>::* 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 <type_var1,type_var2,type_var3,type_var4>::* func##type_var1##type_var2##type_var3##type_var4##concept)(); \
template <func##type_var1##type_var2##type_var3##type_var4##concept _Tp1> \
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 <type_var1,type_var2,type_var3,type_var4>::constraints> \
+ &ns::concept <type_var1,type_var2,type_var3,type_var4>::constraints> \
concept_checking_typedef_##type_var1##type_var2##type_var3##type_var4##concept
-#endif
-
-#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T, class U>
struct require_same { };
template <class T>
struct require_same<T,T> { typedef T type; };
-#else
-// This version does not perform checking, but will not do any harm.
-template <class T, class U>
-struct require_same { typedef T type; };
-#endif
+
+ template <class T, class U>
+ struct SameTypeConcept
+ {
+ void constraints() {
+ typedef typename require_same<T, U>::type req;
+ }
+ };
template <class T>
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<short> { void constraints() {} };
template <> struct IntegerConcept<unsigned short> { void constraints() {} };
template <> struct IntegerConcept<int> { void constraints() {} };
@@ -108,32 +87,24 @@
template <> struct IntegerConcept<long> { void constraints() {} };
template <> struct IntegerConcept<unsigned long> { void constraints() {} };
// etc.
-#endif
template <class T>
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<short> { void constraints() {} };
template <> struct SignedIntegerConcept<int> { void constraints() {} };
template <> struct SignedIntegerConcept<long> { void constraints() {} };
// etc.
-#endif
template <class T>
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<unsigned short>
{ void constraints() {} };
template <> struct UnsignedIntegerConcept<unsigned int>
@@ -141,7 +112,6 @@
template <> struct UnsignedIntegerConcept<unsigned long>
{ 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 <class Func>
struct GeneratorConcept<Func,void>
{
@@ -327,7 +291,6 @@
}
Func f;
};
-#endif
template <class Func, class Return, class Arg>
struct UnaryFunctionConcept
@@ -340,7 +303,6 @@
Return r;
};
-#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class Func, class Arg>
struct UnaryFunctionConcept<Func, void, Arg> {
void constraints() {
@@ -348,7 +310,6 @@
}
Func f;
};
-#endif
template <class Func, class Return, class First, class Second>
struct BinaryFunctionConcept
@@ -362,7 +323,6 @@
Return r;
};
-#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class Func, class First, class Second>
struct BinaryFunctionConcept<Func, void, First, Second>
{
@@ -373,7 +333,6 @@
First first;
Second second;
};
-#endif
template <class Func, class Arg>
struct UnaryPredicateConcept
@@ -422,9 +381,7 @@
function_requires< AssignableConcept<TT> >();
function_requires< DefaultConstructibleConcept<TT> >();
function_requires< EqualityComparableConcept<TT> >();
-#ifndef BOOST_NO_STD_ITERATOR_TRAITS
typedef typename std::iterator_traits<TT>::value_type V;
-#endif
(void)*i; // require dereference operator
}
TT i;
@@ -446,7 +403,6 @@
void constraints() {
function_requires< TrivialIteratorConcept<TT> >();
// require iterator_traits typedef's
-#ifndef BOOST_NO_STD_ITERATOR_TRAITS
typedef typename std::iterator_traits<TT>::difference_type D;
function_requires< SignedIntegerConcept<D> >();
typedef typename std::iterator_traits<TT>::reference R;
@@ -455,7 +411,6 @@
function_requires< ConvertibleConcept<
typename std::iterator_traits<TT>::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<TT> >();
-#ifndef BOOST_NO_STD_ITERATOR_TRAITS
function_requires< ConvertibleConcept<
typename std::iterator_traits<TT>::iterator_category,
std::forward_iterator_tag> >();
typedef typename std::iterator_traits<TT>::reference reference;
reference r = *i;
ignore_unused_variable_warning(r);
-#endif
}
TT i;
};
@@ -507,11 +460,9 @@
{
void constraints() {
function_requires< ForwardIteratorConcept<TT> >();
-#ifndef BOOST_NO_STD_ITERATOR_TRAITS
function_requires< ConvertibleConcept<
typename std::iterator_traits<TT>::iterator_category,
std::bidirectional_iterator_tag> >();
-#endif
--i; // require predecrement operator
i--; // require postdecrement operator
}
@@ -536,12 +487,10 @@
void constraints() {
function_requires< BidirectionalIteratorConcept<TT> >();
function_requires< ComparableConcept<TT> >();
-#ifndef BOOST_NO_STD_ITERATOR_TRAITS
function_requires< ConvertibleConcept<
typename std::iterator_traits<TT>::iterator_category,
std::random_access_iterator_tag> >();
typedef typename std::iterator_traits<TT>::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<TT>::difference_type n;
-#else
- std::ptrdiff_t n;
-#endif
};
template <class TT>
@@ -568,11 +513,7 @@
i[n] = *i; // require element access and assignment
}
TT i;
-#ifndef BOOST_NO_STD_ITERATOR_TRAITS
typename std::iterator_traits<TT>::difference_type n;
-#else
- std::ptrdiff_t n;
-#endif
};
//===========================================================================
|