Merge from mainline (168000:168310).
[official-gcc/graphite-test-results.git] / libstdc++-v3 / include / bits / boost_concept_check.h
blobbeabbb56cb08f8877140e386fe98f72507d8e638
1 // -*- C++ -*-
3 // Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 // <http://www.gnu.org/licenses/>.
26 // (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify,
27 // sell and distribute this software is granted provided this
28 // copyright notice appears in all copies. This software is provided
29 // "as is" without express or implied warranty, and with no claim as
30 // to its suitability for any purpose.
33 /** @file bits/boost_concept_check.h
34 * This is an internal header file, included by other library headers.
35 * Do not attempt to use it directly. @headername{iterator}
38 // GCC Note: based on version 1.12.0 of the Boost library.
40 #ifndef _BOOST_CONCEPT_CHECK_H
41 #define _BOOST_CONCEPT_CHECK_H 1
43 #pragma GCC system_header
45 #include <bits/c++config.h>
46 #include <bits/stl_iterator_base_types.h> // for traits and tags
48 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
50 #define _IsUnused __attribute__ ((__unused__))
52 // When the C-C code is in use, we would like this function to do as little
53 // as possible at runtime, use as few resources as possible, and hopefully
54 // be elided out of existence... hmmm.
55 template <class _Concept>
56 inline void __function_requires()
58 void (_Concept::*__x)() _IsUnused = &_Concept::__constraints;
61 // No definition: if this is referenced, there's a problem with
62 // the instantiating type not being one of the required integer types.
63 // Unfortunately, this results in a link-time error, not a compile-time error.
64 void __error_type_must_be_an_integer_type();
65 void __error_type_must_be_an_unsigned_integer_type();
66 void __error_type_must_be_a_signed_integer_type();
68 // ??? Should the "concept_checking*" structs begin with more than _ ?
69 #define _GLIBCXX_CLASS_REQUIRES(_type_var, _ns, _concept) \
70 typedef void (_ns::_concept <_type_var>::* _func##_type_var##_concept)(); \
71 template <_func##_type_var##_concept _Tp1> \
72 struct _concept_checking##_type_var##_concept { }; \
73 typedef _concept_checking##_type_var##_concept< \
74 &_ns::_concept <_type_var>::__constraints> \
75 _concept_checking_typedef##_type_var##_concept
77 #define _GLIBCXX_CLASS_REQUIRES2(_type_var1, _type_var2, _ns, _concept) \
78 typedef void (_ns::_concept <_type_var1,_type_var2>::* _func##_type_var1##_type_var2##_concept)(); \
79 template <_func##_type_var1##_type_var2##_concept _Tp1> \
80 struct _concept_checking##_type_var1##_type_var2##_concept { }; \
81 typedef _concept_checking##_type_var1##_type_var2##_concept< \
82 &_ns::_concept <_type_var1,_type_var2>::__constraints> \
83 _concept_checking_typedef##_type_var1##_type_var2##_concept
85 #define _GLIBCXX_CLASS_REQUIRES3(_type_var1, _type_var2, _type_var3, _ns, _concept) \
86 typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3>::* _func##_type_var1##_type_var2##_type_var3##_concept)(); \
87 template <_func##_type_var1##_type_var2##_type_var3##_concept _Tp1> \
88 struct _concept_checking##_type_var1##_type_var2##_type_var3##_concept { }; \
89 typedef _concept_checking##_type_var1##_type_var2##_type_var3##_concept< \
90 &_ns::_concept <_type_var1,_type_var2,_type_var3>::__constraints> \
91 _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_concept
93 #define _GLIBCXX_CLASS_REQUIRES4(_type_var1, _type_var2, _type_var3, _type_var4, _ns, _concept) \
94 typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::* _func##_type_var1##_type_var2##_type_var3##_type_var4##_concept)(); \
95 template <_func##_type_var1##_type_var2##_type_var3##_type_var4##_concept _Tp1> \
96 struct _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept { }; \
97 typedef _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept< \
98 &_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::__constraints> \
99 _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_type_var4##_concept
102 template <class _Tp1, class _Tp2>
103 struct _Aux_require_same { };
105 template <class _Tp>
106 struct _Aux_require_same<_Tp,_Tp> { typedef _Tp _Type; };
108 template <class _Tp1, class _Tp2>
109 struct _SameTypeConcept
111 void __constraints() {
112 typedef typename _Aux_require_same<_Tp1, _Tp2>::_Type _Required;
116 template <class _Tp>
117 struct _IntegerConcept {
118 void __constraints() {
119 __error_type_must_be_an_integer_type();
122 template <> struct _IntegerConcept<short> { void __constraints() {} };
123 template <> struct _IntegerConcept<unsigned short> { void __constraints(){} };
124 template <> struct _IntegerConcept<int> { void __constraints() {} };
125 template <> struct _IntegerConcept<unsigned int> { void __constraints() {} };
126 template <> struct _IntegerConcept<long> { void __constraints() {} };
127 template <> struct _IntegerConcept<unsigned long> { void __constraints() {} };
128 template <> struct _IntegerConcept<long long> { void __constraints() {} };
129 template <> struct _IntegerConcept<unsigned long long>
130 { void __constraints() {} };
132 template <class _Tp>
133 struct _SignedIntegerConcept {
134 void __constraints() {
135 __error_type_must_be_a_signed_integer_type();
138 template <> struct _SignedIntegerConcept<short> { void __constraints() {} };
139 template <> struct _SignedIntegerConcept<int> { void __constraints() {} };
140 template <> struct _SignedIntegerConcept<long> { void __constraints() {} };
141 template <> struct _SignedIntegerConcept<long long> { void __constraints(){}};
143 template <class _Tp>
144 struct _UnsignedIntegerConcept {
145 void __constraints() {
146 __error_type_must_be_an_unsigned_integer_type();
149 template <> struct _UnsignedIntegerConcept<unsigned short>
150 { void __constraints() {} };
151 template <> struct _UnsignedIntegerConcept<unsigned int>
152 { void __constraints() {} };
153 template <> struct _UnsignedIntegerConcept<unsigned long>
154 { void __constraints() {} };
155 template <> struct _UnsignedIntegerConcept<unsigned long long>
156 { void __constraints() {} };
158 //===========================================================================
159 // Basic Concepts
161 template <class _Tp>
162 struct _DefaultConstructibleConcept
164 void __constraints() {
165 _Tp __a _IsUnused; // require default constructor
169 template <class _Tp>
170 struct _AssignableConcept
172 void __constraints() {
173 __a = __a; // require assignment operator
174 __const_constraints(__a);
176 void __const_constraints(const _Tp& __b) {
177 __a = __b; // const required for argument to assignment
179 _Tp __a;
180 // possibly should be "Tp* a;" and then dereference "a" in constraint
181 // functions? present way would require a default ctor, i think...
184 template <class _Tp>
185 struct _CopyConstructibleConcept
187 void __constraints() {
188 _Tp __a(__b); // require copy constructor
189 _Tp* __ptr _IsUnused = &__a; // require address of operator
190 __const_constraints(__a);
192 void __const_constraints(const _Tp& __a) {
193 _Tp __c _IsUnused(__a); // require const copy constructor
194 const _Tp* __ptr _IsUnused = &__a; // require const address of operator
196 _Tp __b;
199 // The SGI STL version of Assignable requires copy constructor and operator=
200 template <class _Tp>
201 struct _SGIAssignableConcept
203 void __constraints() {
204 _Tp __b _IsUnused(__a);
205 __a = __a; // require assignment operator
206 __const_constraints(__a);
208 void __const_constraints(const _Tp& __b) {
209 _Tp __c _IsUnused(__b);
210 __a = __b; // const required for argument to assignment
212 _Tp __a;
215 template <class _From, class _To>
216 struct _ConvertibleConcept
218 void __constraints() {
219 _To __y _IsUnused = __x;
221 _From __x;
224 // The C++ standard requirements for many concepts talk about return
225 // types that must be "convertible to bool". The problem with this
226 // requirement is that it leaves the door open for evil proxies that
227 // define things like operator|| with strange return types. Two
228 // possible solutions are:
229 // 1) require the return type to be exactly bool
230 // 2) stay with convertible to bool, and also
231 // specify stuff about all the logical operators.
232 // For now we just test for convertible to bool.
233 template <class _Tp>
234 void __aux_require_boolean_expr(const _Tp& __t) {
235 bool __x _IsUnused = __t;
238 // FIXME
239 template <class _Tp>
240 struct _EqualityComparableConcept
242 void __constraints() {
243 __aux_require_boolean_expr(__a == __b);
245 _Tp __a, __b;
248 template <class _Tp>
249 struct _LessThanComparableConcept
251 void __constraints() {
252 __aux_require_boolean_expr(__a < __b);
254 _Tp __a, __b;
257 // This is equivalent to SGI STL's LessThanComparable.
258 template <class _Tp>
259 struct _ComparableConcept
261 void __constraints() {
262 __aux_require_boolean_expr(__a < __b);
263 __aux_require_boolean_expr(__a > __b);
264 __aux_require_boolean_expr(__a <= __b);
265 __aux_require_boolean_expr(__a >= __b);
267 _Tp __a, __b;
270 #define _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(_OP,_NAME) \
271 template <class _First, class _Second> \
272 struct _NAME { \
273 void __constraints() { (void)__constraints_(); } \
274 bool __constraints_() { \
275 return __a _OP __b; \
277 _First __a; \
278 _Second __b; \
281 #define _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(_OP,_NAME) \
282 template <class _Ret, class _First, class _Second> \
283 struct _NAME { \
284 void __constraints() { (void)__constraints_(); } \
285 _Ret __constraints_() { \
286 return __a _OP __b; \
288 _First __a; \
289 _Second __b; \
292 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(==, _EqualOpConcept);
293 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(!=, _NotEqualOpConcept);
294 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<, _LessThanOpConcept);
295 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<=, _LessEqualOpConcept);
296 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>, _GreaterThanOpConcept);
297 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>=, _GreaterEqualOpConcept);
299 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(+, _PlusOpConcept);
300 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(*, _TimesOpConcept);
301 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(/, _DivideOpConcept);
302 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(-, _SubtractOpConcept);
303 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(%, _ModOpConcept);
305 #undef _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT
306 #undef _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT
308 //===========================================================================
309 // Function Object Concepts
311 template <class _Func, class _Return>
312 struct _GeneratorConcept
314 void __constraints() {
315 const _Return& __r _IsUnused = __f();// require operator() member function
317 _Func __f;
321 template <class _Func>
322 struct _GeneratorConcept<_Func,void>
324 void __constraints() {
325 __f(); // require operator() member function
327 _Func __f;
330 template <class _Func, class _Return, class _Arg>
331 struct _UnaryFunctionConcept
333 void __constraints() {
334 __r = __f(__arg); // require operator()
336 _Func __f;
337 _Arg __arg;
338 _Return __r;
341 template <class _Func, class _Arg>
342 struct _UnaryFunctionConcept<_Func, void, _Arg> {
343 void __constraints() {
344 __f(__arg); // require operator()
346 _Func __f;
347 _Arg __arg;
350 template <class _Func, class _Return, class _First, class _Second>
351 struct _BinaryFunctionConcept
353 void __constraints() {
354 __r = __f(__first, __second); // require operator()
356 _Func __f;
357 _First __first;
358 _Second __second;
359 _Return __r;
362 template <class _Func, class _First, class _Second>
363 struct _BinaryFunctionConcept<_Func, void, _First, _Second>
365 void __constraints() {
366 __f(__first, __second); // require operator()
368 _Func __f;
369 _First __first;
370 _Second __second;
373 template <class _Func, class _Arg>
374 struct _UnaryPredicateConcept
376 void __constraints() {
377 __aux_require_boolean_expr(__f(__arg)); // require op() returning bool
379 _Func __f;
380 _Arg __arg;
383 template <class _Func, class _First, class _Second>
384 struct _BinaryPredicateConcept
386 void __constraints() {
387 __aux_require_boolean_expr(__f(__a, __b)); // require op() returning bool
389 _Func __f;
390 _First __a;
391 _Second __b;
394 // use this when functor is used inside a container class like std::set
395 template <class _Func, class _First, class _Second>
396 struct _Const_BinaryPredicateConcept {
397 void __constraints() {
398 __const_constraints(__f);
400 void __const_constraints(const _Func& __fun) {
401 __function_requires<_BinaryPredicateConcept<_Func, _First, _Second> >();
402 // operator() must be a const member function
403 __aux_require_boolean_expr(__fun(__a, __b));
405 _Func __f;
406 _First __a;
407 _Second __b;
410 //===========================================================================
411 // Iterator Concepts
413 template <class _Tp>
414 struct _TrivialIteratorConcept
416 void __constraints() {
417 // __function_requires< _DefaultConstructibleConcept<_Tp> >();
418 __function_requires< _AssignableConcept<_Tp> >();
419 __function_requires< _EqualityComparableConcept<_Tp> >();
420 // typedef typename std::iterator_traits<_Tp>::value_type _V;
421 (void)*__i; // require dereference operator
423 _Tp __i;
426 template <class _Tp>
427 struct _Mutable_TrivialIteratorConcept
429 void __constraints() {
430 __function_requires< _TrivialIteratorConcept<_Tp> >();
431 *__i = *__j; // require dereference and assignment
433 _Tp __i, __j;
436 template <class _Tp>
437 struct _InputIteratorConcept
439 void __constraints() {
440 __function_requires< _TrivialIteratorConcept<_Tp> >();
441 // require iterator_traits typedef's
442 typedef typename std::iterator_traits<_Tp>::difference_type _Diff;
443 // __function_requires< _SignedIntegerConcept<_Diff> >();
444 typedef typename std::iterator_traits<_Tp>::reference _Ref;
445 typedef typename std::iterator_traits<_Tp>::pointer _Pt;
446 typedef typename std::iterator_traits<_Tp>::iterator_category _Cat;
447 __function_requires< _ConvertibleConcept<
448 typename std::iterator_traits<_Tp>::iterator_category,
449 std::input_iterator_tag> >();
450 ++__i; // require preincrement operator
451 __i++; // require postincrement operator
453 _Tp __i;
456 template <class _Tp, class _ValueT>
457 struct _OutputIteratorConcept
459 void __constraints() {
460 __function_requires< _AssignableConcept<_Tp> >();
461 ++__i; // require preincrement operator
462 __i++; // require postincrement operator
463 *__i++ = __t; // require postincrement and assignment
465 _Tp __i;
466 _ValueT __t;
469 template <class _Tp>
470 struct _ForwardIteratorConcept
472 void __constraints() {
473 __function_requires< _InputIteratorConcept<_Tp> >();
474 __function_requires< _DefaultConstructibleConcept<_Tp> >();
475 __function_requires< _ConvertibleConcept<
476 typename std::iterator_traits<_Tp>::iterator_category,
477 std::forward_iterator_tag> >();
478 typedef typename std::iterator_traits<_Tp>::reference _Ref;
479 _Ref __r _IsUnused = *__i;
481 _Tp __i;
484 template <class _Tp>
485 struct _Mutable_ForwardIteratorConcept
487 void __constraints() {
488 __function_requires< _ForwardIteratorConcept<_Tp> >();
489 *__i++ = *__i; // require postincrement and assignment
491 _Tp __i;
494 template <class _Tp>
495 struct _BidirectionalIteratorConcept
497 void __constraints() {
498 __function_requires< _ForwardIteratorConcept<_Tp> >();
499 __function_requires< _ConvertibleConcept<
500 typename std::iterator_traits<_Tp>::iterator_category,
501 std::bidirectional_iterator_tag> >();
502 --__i; // require predecrement operator
503 __i--; // require postdecrement operator
505 _Tp __i;
508 template <class _Tp>
509 struct _Mutable_BidirectionalIteratorConcept
511 void __constraints() {
512 __function_requires< _BidirectionalIteratorConcept<_Tp> >();
513 __function_requires< _Mutable_ForwardIteratorConcept<_Tp> >();
514 *__i-- = *__i; // require postdecrement and assignment
516 _Tp __i;
520 template <class _Tp>
521 struct _RandomAccessIteratorConcept
523 void __constraints() {
524 __function_requires< _BidirectionalIteratorConcept<_Tp> >();
525 __function_requires< _ComparableConcept<_Tp> >();
526 __function_requires< _ConvertibleConcept<
527 typename std::iterator_traits<_Tp>::iterator_category,
528 std::random_access_iterator_tag> >();
529 // ??? We don't use _Ref, are we just checking for "referenceability"?
530 typedef typename std::iterator_traits<_Tp>::reference _Ref;
532 __i += __n; // require assignment addition operator
533 __i = __i + __n; __i = __n + __i; // require addition with difference type
534 __i -= __n; // require assignment subtraction op
535 __i = __i - __n; // require subtraction with
536 // difference type
537 __n = __i - __j; // require difference operator
538 (void)__i[__n]; // require element access operator
540 _Tp __a, __b;
541 _Tp __i, __j;
542 typename std::iterator_traits<_Tp>::difference_type __n;
545 template <class _Tp>
546 struct _Mutable_RandomAccessIteratorConcept
548 void __constraints() {
549 __function_requires< _RandomAccessIteratorConcept<_Tp> >();
550 __function_requires< _Mutable_BidirectionalIteratorConcept<_Tp> >();
551 __i[__n] = *__i; // require element access and assignment
553 _Tp __i;
554 typename std::iterator_traits<_Tp>::difference_type __n;
557 //===========================================================================
558 // Container Concepts
560 template <class _Container>
561 struct _ContainerConcept
563 typedef typename _Container::value_type _Value_type;
564 typedef typename _Container::difference_type _Difference_type;
565 typedef typename _Container::size_type _Size_type;
566 typedef typename _Container::const_reference _Const_reference;
567 typedef typename _Container::const_pointer _Const_pointer;
568 typedef typename _Container::const_iterator _Const_iterator;
570 void __constraints() {
571 __function_requires< _InputIteratorConcept<_Const_iterator> >();
572 __function_requires< _AssignableConcept<_Container> >();
573 const _Container __c;
574 __i = __c.begin();
575 __i = __c.end();
576 __n = __c.size();
577 __n = __c.max_size();
578 __b = __c.empty();
580 bool __b;
581 _Const_iterator __i;
582 _Size_type __n;
585 template <class _Container>
586 struct _Mutable_ContainerConcept
588 typedef typename _Container::value_type _Value_type;
589 typedef typename _Container::reference _Reference;
590 typedef typename _Container::iterator _Iterator;
591 typedef typename _Container::pointer _Pointer;
593 void __constraints() {
594 __function_requires< _ContainerConcept<_Container> >();
595 __function_requires< _AssignableConcept<_Value_type> >();
596 __function_requires< _InputIteratorConcept<_Iterator> >();
598 __i = __c.begin();
599 __i = __c.end();
600 __c.swap(__c2);
602 _Iterator __i;
603 _Container __c, __c2;
606 template <class _ForwardContainer>
607 struct _ForwardContainerConcept
609 void __constraints() {
610 __function_requires< _ContainerConcept<_ForwardContainer> >();
611 typedef typename _ForwardContainer::const_iterator _Const_iterator;
612 __function_requires< _ForwardIteratorConcept<_Const_iterator> >();
616 template <class _ForwardContainer>
617 struct _Mutable_ForwardContainerConcept
619 void __constraints() {
620 __function_requires< _ForwardContainerConcept<_ForwardContainer> >();
621 __function_requires< _Mutable_ContainerConcept<_ForwardContainer> >();
622 typedef typename _ForwardContainer::iterator _Iterator;
623 __function_requires< _Mutable_ForwardIteratorConcept<_Iterator> >();
627 template <class _ReversibleContainer>
628 struct _ReversibleContainerConcept
630 typedef typename _ReversibleContainer::const_iterator _Const_iterator;
631 typedef typename _ReversibleContainer::const_reverse_iterator
632 _Const_reverse_iterator;
634 void __constraints() {
635 __function_requires< _ForwardContainerConcept<_ReversibleContainer> >();
636 __function_requires< _BidirectionalIteratorConcept<_Const_iterator> >();
637 __function_requires<
638 _BidirectionalIteratorConcept<_Const_reverse_iterator> >();
640 const _ReversibleContainer __c;
641 _Const_reverse_iterator __i = __c.rbegin();
642 __i = __c.rend();
646 template <class _ReversibleContainer>
647 struct _Mutable_ReversibleContainerConcept
649 typedef typename _ReversibleContainer::iterator _Iterator;
650 typedef typename _ReversibleContainer::reverse_iterator _Reverse_iterator;
652 void __constraints() {
653 __function_requires<_ReversibleContainerConcept<_ReversibleContainer> >();
654 __function_requires<
655 _Mutable_ForwardContainerConcept<_ReversibleContainer> >();
656 __function_requires<_Mutable_BidirectionalIteratorConcept<_Iterator> >();
657 __function_requires<
658 _Mutable_BidirectionalIteratorConcept<_Reverse_iterator> >();
660 _Reverse_iterator __i = __c.rbegin();
661 __i = __c.rend();
663 _ReversibleContainer __c;
666 template <class _RandomAccessContainer>
667 struct _RandomAccessContainerConcept
669 typedef typename _RandomAccessContainer::size_type _Size_type;
670 typedef typename _RandomAccessContainer::const_reference _Const_reference;
671 typedef typename _RandomAccessContainer::const_iterator _Const_iterator;
672 typedef typename _RandomAccessContainer::const_reverse_iterator
673 _Const_reverse_iterator;
675 void __constraints() {
676 __function_requires<
677 _ReversibleContainerConcept<_RandomAccessContainer> >();
678 __function_requires< _RandomAccessIteratorConcept<_Const_iterator> >();
679 __function_requires<
680 _RandomAccessIteratorConcept<_Const_reverse_iterator> >();
682 const _RandomAccessContainer __c;
683 _Const_reference __r _IsUnused = __c[__n];
685 _Size_type __n;
688 template <class _RandomAccessContainer>
689 struct _Mutable_RandomAccessContainerConcept
691 typedef typename _RandomAccessContainer::size_type _Size_type;
692 typedef typename _RandomAccessContainer::reference _Reference;
693 typedef typename _RandomAccessContainer::iterator _Iterator;
694 typedef typename _RandomAccessContainer::reverse_iterator _Reverse_iterator;
696 void __constraints() {
697 __function_requires<
698 _RandomAccessContainerConcept<_RandomAccessContainer> >();
699 __function_requires<
700 _Mutable_ReversibleContainerConcept<_RandomAccessContainer> >();
701 __function_requires< _Mutable_RandomAccessIteratorConcept<_Iterator> >();
702 __function_requires<
703 _Mutable_RandomAccessIteratorConcept<_Reverse_iterator> >();
705 _Reference __r _IsUnused = __c[__i];
707 _Size_type __i;
708 _RandomAccessContainer __c;
711 // A Sequence is inherently mutable
712 template <class _Sequence>
713 struct _SequenceConcept
715 typedef typename _Sequence::reference _Reference;
716 typedef typename _Sequence::const_reference _Const_reference;
718 void __constraints() {
719 // Matt Austern's book puts DefaultConstructible here, the C++
720 // standard places it in Container
721 // function_requires< DefaultConstructible<Sequence> >();
722 __function_requires< _Mutable_ForwardContainerConcept<_Sequence> >();
723 __function_requires< _DefaultConstructibleConcept<_Sequence> >();
725 _Sequence
726 __c _IsUnused(__n, __t),
727 __c2 _IsUnused(__first, __last);
729 __c.insert(__p, __t);
730 __c.insert(__p, __n, __t);
731 __c.insert(__p, __first, __last);
733 __c.erase(__p);
734 __c.erase(__p, __q);
736 _Reference __r _IsUnused = __c.front();
738 __const_constraints(__c);
740 void __const_constraints(const _Sequence& __c) {
741 _Const_reference __r _IsUnused = __c.front();
743 typename _Sequence::value_type __t;
744 typename _Sequence::size_type __n;
745 typename _Sequence::value_type *__first, *__last;
746 typename _Sequence::iterator __p, __q;
749 template <class _FrontInsertionSequence>
750 struct _FrontInsertionSequenceConcept
752 void __constraints() {
753 __function_requires< _SequenceConcept<_FrontInsertionSequence> >();
755 __c.push_front(__t);
756 __c.pop_front();
758 _FrontInsertionSequence __c;
759 typename _FrontInsertionSequence::value_type __t;
762 template <class _BackInsertionSequence>
763 struct _BackInsertionSequenceConcept
765 typedef typename _BackInsertionSequence::reference _Reference;
766 typedef typename _BackInsertionSequence::const_reference _Const_reference;
768 void __constraints() {
769 __function_requires< _SequenceConcept<_BackInsertionSequence> >();
771 __c.push_back(__t);
772 __c.pop_back();
773 _Reference __r _IsUnused = __c.back();
775 void __const_constraints(const _BackInsertionSequence& __c) {
776 _Const_reference __r _IsUnused = __c.back();
778 _BackInsertionSequence __c;
779 typename _BackInsertionSequence::value_type __t;
782 _GLIBCXX_END_NAMESPACE
784 #undef _IsUnused
786 #endif // _GLIBCXX_BOOST_CONCEPT_CHECK