40 #ifndef _BOOST_CONCEPT_CHECK_H
41 #define _BOOST_CONCEPT_CHECK_H 1
43 #pragma GCC system_header
48 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
50 _GLIBCXX_BEGIN_NAMESPACE_VERSION
52 #define _IsUnused __attribute__ ((__unused__))
57 template <
class _Concept>
58 inline void __function_requires()
60 void (_Concept::*__x)() _IsUnused = &_Concept::__constraints;
66 void __error_type_must_be_an_integer_type();
67 void __error_type_must_be_an_unsigned_integer_type();
68 void __error_type_must_be_a_signed_integer_type();
71 #define _GLIBCXX_CLASS_REQUIRES(_type_var, _ns, _concept) \
72 typedef void (_ns::_concept <_type_var>::* _func##_type_var##_concept)(); \
73 template <_func##_type_var##_concept _Tp1> \
74 struct _concept_checking##_type_var##_concept { }; \
75 typedef _concept_checking##_type_var##_concept< \
76 &_ns::_concept <_type_var>::__constraints> \
77 _concept_checking_typedef##_type_var##_concept
79 #define _GLIBCXX_CLASS_REQUIRES2(_type_var1, _type_var2, _ns, _concept) \
80 typedef void (_ns::_concept <_type_var1,_type_var2>::* _func##_type_var1##_type_var2##_concept)(); \
81 template <_func##_type_var1##_type_var2##_concept _Tp1> \
82 struct _concept_checking##_type_var1##_type_var2##_concept { }; \
83 typedef _concept_checking##_type_var1##_type_var2##_concept< \
84 &_ns::_concept <_type_var1,_type_var2>::__constraints> \
85 _concept_checking_typedef##_type_var1##_type_var2##_concept
87 #define _GLIBCXX_CLASS_REQUIRES3(_type_var1, _type_var2, _type_var3, _ns, _concept) \
88 typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3>::* _func##_type_var1##_type_var2##_type_var3##_concept)(); \
89 template <_func##_type_var1##_type_var2##_type_var3##_concept _Tp1> \
90 struct _concept_checking##_type_var1##_type_var2##_type_var3##_concept { }; \
91 typedef _concept_checking##_type_var1##_type_var2##_type_var3##_concept< \
92 &_ns::_concept <_type_var1,_type_var2,_type_var3>::__constraints> \
93 _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_concept
95 #define _GLIBCXX_CLASS_REQUIRES4(_type_var1, _type_var2, _type_var3, _type_var4, _ns, _concept) \
96 typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::* _func##_type_var1##_type_var2##_type_var3##_type_var4##_concept)(); \
97 template <_func##_type_var1##_type_var2##_type_var3##_type_var4##_concept _Tp1> \
98 struct _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept { }; \
99 typedef _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept< \
100 &_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::__constraints> \
101 _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_type_var4##_concept
104 template <
class _Tp1,
class _Tp2>
105 struct _Aux_require_same { };
108 struct _Aux_require_same<_Tp,_Tp> {
typedef _Tp _Type; };
110 template <
class _Tp1,
class _Tp2>
111 struct _SameTypeConcept
113 void __constraints() {
114 typedef typename _Aux_require_same<_Tp1, _Tp2>::_Type _Required;
119 struct _IntegerConcept {
120 void __constraints() {
121 __error_type_must_be_an_integer_type();
124 template <>
struct _IntegerConcept<short> {
void __constraints() {} };
125 template <>
struct _IntegerConcept<unsigned short> {
void __constraints(){} };
126 template <>
struct _IntegerConcept<int> {
void __constraints() {} };
127 template <>
struct _IntegerConcept<unsigned int> {
void __constraints() {} };
128 template <>
struct _IntegerConcept<long> {
void __constraints() {} };
129 template <>
struct _IntegerConcept<unsigned long> {
void __constraints() {} };
130 template <>
struct _IntegerConcept<long long> {
void __constraints() {} };
131 template <>
struct _IntegerConcept<unsigned long long>
132 {
void __constraints() {} };
135 struct _SignedIntegerConcept {
136 void __constraints() {
137 __error_type_must_be_a_signed_integer_type();
140 template <>
struct _SignedIntegerConcept<short> {
void __constraints() {} };
141 template <>
struct _SignedIntegerConcept<int> {
void __constraints() {} };
142 template <>
struct _SignedIntegerConcept<long> {
void __constraints() {} };
143 template <>
struct _SignedIntegerConcept<long long> {
void __constraints(){}};
146 struct _UnsignedIntegerConcept {
147 void __constraints() {
148 __error_type_must_be_an_unsigned_integer_type();
151 template <>
struct _UnsignedIntegerConcept<unsigned short>
152 {
void __constraints() {} };
153 template <>
struct _UnsignedIntegerConcept<unsigned int>
154 {
void __constraints() {} };
155 template <>
struct _UnsignedIntegerConcept<unsigned long>
156 {
void __constraints() {} };
157 template <>
struct _UnsignedIntegerConcept<unsigned long long>
158 {
void __constraints() {} };
164 struct _DefaultConstructibleConcept
166 void __constraints() {
172 struct _AssignableConcept
174 void __constraints() {
176 __const_constraints(__a);
178 void __const_constraints(
const _Tp& __b) {
187 struct _CopyConstructibleConcept
189 void __constraints() {
191 _Tp* __ptr _IsUnused = &__a;
192 __const_constraints(__a);
194 void __const_constraints(
const _Tp& __a) {
195 _Tp __c _IsUnused(__a);
196 const _Tp* __ptr _IsUnused = &__a;
203 struct _SGIAssignableConcept
205 void __constraints() {
206 _Tp __b _IsUnused(__a);
208 __const_constraints(__a);
210 void __const_constraints(
const _Tp& __b) {
211 _Tp __c _IsUnused(__b);
217 template <
class _From,
class _To>
218 struct _ConvertibleConcept
220 void __constraints() {
221 _To __y _IsUnused = __x;
236 void __aux_require_boolean_expr(
const _Tp& __t) {
237 bool __x _IsUnused = __t;
242 struct _EqualityComparableConcept
244 void __constraints() {
245 __aux_require_boolean_expr(__a == __b);
251 struct _LessThanComparableConcept
253 void __constraints() {
254 __aux_require_boolean_expr(__a < __b);
261 struct _ComparableConcept
263 void __constraints() {
264 __aux_require_boolean_expr(__a < __b);
265 __aux_require_boolean_expr(__a > __b);
266 __aux_require_boolean_expr(__a <= __b);
267 __aux_require_boolean_expr(__a >= __b);
272 #define _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(_OP,_NAME) \
273 template <class _First, class _Second> \
275 void __constraints() { (void)__constraints_(); } \
276 bool __constraints_() { \
277 return __a _OP __b; \
283 #define _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(_OP,_NAME) \
284 template <class _Ret, class _First, class _Second> \
286 void __constraints() { (void)__constraints_(); } \
287 _Ret __constraints_() { \
288 return __a _OP __b; \
294 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(==, _EqualOpConcept);
295 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(!=, _NotEqualOpConcept);
296 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<, _LessThanOpConcept);
297 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<=, _LessEqualOpConcept);
298 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>, _GreaterThanOpConcept);
299 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>=, _GreaterEqualOpConcept);
301 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(+, _PlusOpConcept);
302 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(*, _TimesOpConcept);
303 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(/, _DivideOpConcept);
304 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(-, _SubtractOpConcept);
305 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(%, _ModOpConcept);
307 #undef _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT
308 #undef _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT
313 template <
class _Func,
class _Return>
314 struct _GeneratorConcept
316 void __constraints() {
317 const _Return& __r _IsUnused = __f();
323 template <
class _Func>
324 struct _GeneratorConcept<_Func,void>
326 void __constraints() {
332 template <
class _Func,
class _Return,
class _Arg>
333 struct _UnaryFunctionConcept
335 void __constraints() {
343 template <
class _Func,
class _Arg>
344 struct _UnaryFunctionConcept<_Func, void, _Arg> {
345 void __constraints() {
352 template <
class _Func,
class _Return,
class _First,
class _Second>
353 struct _BinaryFunctionConcept
355 void __constraints() {
356 __r = __f(__first, __second);
364 template <
class _Func,
class _First,
class _Second>
365 struct _BinaryFunctionConcept<_Func, void, _First, _Second>
367 void __constraints() {
368 __f(__first, __second);
375 template <
class _Func,
class _Arg>
376 struct _UnaryPredicateConcept
378 void __constraints() {
379 __aux_require_boolean_expr(__f(__arg));
385 template <
class _Func,
class _First,
class _Second>
386 struct _BinaryPredicateConcept
388 void __constraints() {
389 __aux_require_boolean_expr(__f(__a, __b));
397 template <
class _Func,
class _First,
class _Second>
398 struct _Const_BinaryPredicateConcept {
399 void __constraints() {
400 __const_constraints(__f);
402 void __const_constraints(
const _Func& __fun) {
403 __function_requires<_BinaryPredicateConcept<_Func, _First, _Second> >();
405 __aux_require_boolean_expr(__fun(__a, __b));
416 struct _TrivialIteratorConcept
418 void __constraints() {
420 __function_requires< _AssignableConcept<_Tp> >();
421 __function_requires< _EqualityComparableConcept<_Tp> >();
429 struct _Mutable_TrivialIteratorConcept
431 void __constraints() {
432 __function_requires< _TrivialIteratorConcept<_Tp> >();
439 struct _InputIteratorConcept
441 void __constraints() {
442 __function_requires< _TrivialIteratorConcept<_Tp> >();
444 typedef typename std::iterator_traits<_Tp>::difference_type _Diff;
446 typedef typename std::iterator_traits<_Tp>::reference _Ref;
447 typedef typename std::iterator_traits<_Tp>::pointer _Pt;
448 typedef typename std::iterator_traits<_Tp>::iterator_category _Cat;
449 __function_requires< _ConvertibleConcept<
450 typename std::iterator_traits<_Tp>::iterator_category,
458 template <
class _Tp,
class _ValueT>
459 struct _OutputIteratorConcept
461 void __constraints() {
462 __function_requires< _AssignableConcept<_Tp> >();
472 struct _ForwardIteratorConcept
474 void __constraints() {
475 __function_requires< _InputIteratorConcept<_Tp> >();
476 __function_requires< _DefaultConstructibleConcept<_Tp> >();
477 __function_requires< _ConvertibleConcept<
478 typename std::iterator_traits<_Tp>::iterator_category,
480 typedef typename std::iterator_traits<_Tp>::reference _Ref;
481 _Ref __r _IsUnused = *__i;
487 struct _Mutable_ForwardIteratorConcept
489 void __constraints() {
490 __function_requires< _ForwardIteratorConcept<_Tp> >();
497 struct _BidirectionalIteratorConcept
499 void __constraints() {
500 __function_requires< _ForwardIteratorConcept<_Tp> >();
501 __function_requires< _ConvertibleConcept<
502 typename std::iterator_traits<_Tp>::iterator_category,
511 struct _Mutable_BidirectionalIteratorConcept
513 void __constraints() {
514 __function_requires< _BidirectionalIteratorConcept<_Tp> >();
515 __function_requires< _Mutable_ForwardIteratorConcept<_Tp> >();
523 struct _RandomAccessIteratorConcept
525 void __constraints() {
526 __function_requires< _BidirectionalIteratorConcept<_Tp> >();
527 __function_requires< _ComparableConcept<_Tp> >();
528 __function_requires< _ConvertibleConcept<
529 typename std::iterator_traits<_Tp>::iterator_category,
532 typedef typename std::iterator_traits<_Tp>::reference _Ref;
535 __i = __i + __n; __i = __n + __i;
544 typename std::iterator_traits<_Tp>::difference_type __n;
548 struct _Mutable_RandomAccessIteratorConcept
550 void __constraints() {
551 __function_requires< _RandomAccessIteratorConcept<_Tp> >();
552 __function_requires< _Mutable_BidirectionalIteratorConcept<_Tp> >();
556 typename std::iterator_traits<_Tp>::difference_type __n;
562 template <
class _Container>
563 struct _ContainerConcept
565 typedef typename _Container::value_type _Value_type;
566 typedef typename _Container::difference_type _Difference_type;
567 typedef typename _Container::size_type _Size_type;
568 typedef typename _Container::const_reference _Const_reference;
569 typedef typename _Container::const_pointer _Const_pointer;
570 typedef typename _Container::const_iterator _Const_iterator;
572 void __constraints() {
573 __function_requires< _InputIteratorConcept<_Const_iterator> >();
574 __function_requires< _AssignableConcept<_Container> >();
575 const _Container __c;
579 __n = __c.max_size();
587 template <
class _Container>
588 struct _Mutable_ContainerConcept
590 typedef typename _Container::value_type _Value_type;
591 typedef typename _Container::reference _Reference;
592 typedef typename _Container::iterator _Iterator;
593 typedef typename _Container::pointer _Pointer;
595 void __constraints() {
596 __function_requires< _ContainerConcept<_Container> >();
597 __function_requires< _AssignableConcept<_Value_type> >();
598 __function_requires< _InputIteratorConcept<_Iterator> >();
605 _Container __c, __c2;
608 template <
class _ForwardContainer>
609 struct _ForwardContainerConcept
611 void __constraints() {
612 __function_requires< _ContainerConcept<_ForwardContainer> >();
613 typedef typename _ForwardContainer::const_iterator _Const_iterator;
614 __function_requires< _ForwardIteratorConcept<_Const_iterator> >();
618 template <
class _ForwardContainer>
619 struct _Mutable_ForwardContainerConcept
621 void __constraints() {
622 __function_requires< _ForwardContainerConcept<_ForwardContainer> >();
623 __function_requires< _Mutable_ContainerConcept<_ForwardContainer> >();
624 typedef typename _ForwardContainer::iterator _Iterator;
625 __function_requires< _Mutable_ForwardIteratorConcept<_Iterator> >();
629 template <
class _ReversibleContainer>
630 struct _ReversibleContainerConcept
632 typedef typename _ReversibleContainer::const_iterator _Const_iterator;
633 typedef typename _ReversibleContainer::const_reverse_iterator
634 _Const_reverse_iterator;
636 void __constraints() {
637 __function_requires< _ForwardContainerConcept<_ReversibleContainer> >();
638 __function_requires< _BidirectionalIteratorConcept<_Const_iterator> >();
640 _BidirectionalIteratorConcept<_Const_reverse_iterator> >();
642 const _ReversibleContainer __c;
643 _Const_reverse_iterator __i = __c.rbegin();
648 template <
class _ReversibleContainer>
649 struct _Mutable_ReversibleContainerConcept
651 typedef typename _ReversibleContainer::iterator _Iterator;
652 typedef typename _ReversibleContainer::reverse_iterator _Reverse_iterator;
654 void __constraints() {
655 __function_requires<_ReversibleContainerConcept<_ReversibleContainer> >();
657 _Mutable_ForwardContainerConcept<_ReversibleContainer> >();
658 __function_requires<_Mutable_BidirectionalIteratorConcept<_Iterator> >();
660 _Mutable_BidirectionalIteratorConcept<_Reverse_iterator> >();
662 _Reverse_iterator __i = __c.rbegin();
665 _ReversibleContainer __c;
668 template <
class _RandomAccessContainer>
669 struct _RandomAccessContainerConcept
671 typedef typename _RandomAccessContainer::size_type _Size_type;
672 typedef typename _RandomAccessContainer::const_reference _Const_reference;
673 typedef typename _RandomAccessContainer::const_iterator _Const_iterator;
674 typedef typename _RandomAccessContainer::const_reverse_iterator
675 _Const_reverse_iterator;
677 void __constraints() {
679 _ReversibleContainerConcept<_RandomAccessContainer> >();
680 __function_requires< _RandomAccessIteratorConcept<_Const_iterator> >();
682 _RandomAccessIteratorConcept<_Const_reverse_iterator> >();
684 const _RandomAccessContainer __c;
685 _Const_reference __r _IsUnused = __c[__n];
690 template <
class _RandomAccessContainer>
691 struct _Mutable_RandomAccessContainerConcept
693 typedef typename _RandomAccessContainer::size_type _Size_type;
694 typedef typename _RandomAccessContainer::reference _Reference;
695 typedef typename _RandomAccessContainer::iterator _Iterator;
696 typedef typename _RandomAccessContainer::reverse_iterator _Reverse_iterator;
698 void __constraints() {
700 _RandomAccessContainerConcept<_RandomAccessContainer> >();
702 _Mutable_ReversibleContainerConcept<_RandomAccessContainer> >();
703 __function_requires< _Mutable_RandomAccessIteratorConcept<_Iterator> >();
705 _Mutable_RandomAccessIteratorConcept<_Reverse_iterator> >();
707 _Reference __r _IsUnused = __c[__i];
710 _RandomAccessContainer __c;
714 template <
class _Sequence>
715 struct _SequenceConcept
717 typedef typename _Sequence::reference _Reference;
718 typedef typename _Sequence::const_reference _Const_reference;
720 void __constraints() {
724 __function_requires< _Mutable_ForwardContainerConcept<_Sequence> >();
725 __function_requires< _DefaultConstructibleConcept<_Sequence> >();
728 __c _IsUnused(__n, __t),
729 __c2 _IsUnused(__first, __last);
731 __c.insert(__p, __t);
732 __c.insert(__p, __n, __t);
733 __c.insert(__p, __first, __last);
738 _Reference __r _IsUnused = __c.front();
740 __const_constraints(__c);
742 void __const_constraints(
const _Sequence& __c) {
743 _Const_reference __r _IsUnused = __c.front();
745 typename _Sequence::value_type __t;
746 typename _Sequence::size_type __n;
747 typename _Sequence::value_type *__first, *__last;
748 typename _Sequence::iterator __p, __q;
751 template <
class _FrontInsertionSequence>
752 struct _FrontInsertionSequenceConcept
754 void __constraints() {
755 __function_requires< _SequenceConcept<_FrontInsertionSequence> >();
760 _FrontInsertionSequence __c;
761 typename _FrontInsertionSequence::value_type __t;
764 template <
class _BackInsertionSequence>
765 struct _BackInsertionSequenceConcept
767 typedef typename _BackInsertionSequence::reference _Reference;
768 typedef typename _BackInsertionSequence::const_reference _Const_reference;
770 void __constraints() {
771 __function_requires< _SequenceConcept<_BackInsertionSequence> >();
775 _Reference __r _IsUnused = __c.back();
777 void __const_constraints(
const _BackInsertionSequence& __c) {
778 _Const_reference __r _IsUnused = __c.back();
780 _BackInsertionSequence __c;
781 typename _BackInsertionSequence::value_type __t;
784 _GLIBCXX_END_NAMESPACE_VERSION
789 #endif // _GLIBCXX_BOOST_CONCEPT_CHECK
Forward iterators support a superset of input iterator operations.
Bidirectional iterators support a superset of forward iterator operations.
Random-access iterators support a superset of bidirectional iterator operations.