39 #ifndef _BOOST_CONCEPT_CHECK_H
40 #define _BOOST_CONCEPT_CHECK_H 1
42 #pragma GCC system_header
47 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
49 #define _IsUnused __attribute__ ((__unused__))
54 template <
class _Concept>
55 inline void __function_requires()
57 void (_Concept::*__x)() _IsUnused = &_Concept::__constraints;
63 void __error_type_must_be_an_integer_type();
64 void __error_type_must_be_an_unsigned_integer_type();
65 void __error_type_must_be_a_signed_integer_type();
68 #define _GLIBCXX_CLASS_REQUIRES(_type_var, _ns, _concept) \
69 typedef void (_ns::_concept <_type_var>::* _func##_type_var##_concept)(); \
70 template <_func##_type_var##_concept _Tp1> \
71 struct _concept_checking##_type_var##_concept { }; \
72 typedef _concept_checking##_type_var##_concept< \
73 &_ns::_concept <_type_var>::__constraints> \
74 _concept_checking_typedef##_type_var##_concept
76 #define _GLIBCXX_CLASS_REQUIRES2(_type_var1, _type_var2, _ns, _concept) \
77 typedef void (_ns::_concept <_type_var1,_type_var2>::* _func##_type_var1##_type_var2##_concept)(); \
78 template <_func##_type_var1##_type_var2##_concept _Tp1> \
79 struct _concept_checking##_type_var1##_type_var2##_concept { }; \
80 typedef _concept_checking##_type_var1##_type_var2##_concept< \
81 &_ns::_concept <_type_var1,_type_var2>::__constraints> \
82 _concept_checking_typedef##_type_var1##_type_var2##_concept
84 #define _GLIBCXX_CLASS_REQUIRES3(_type_var1, _type_var2, _type_var3, _ns, _concept) \
85 typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3>::* _func##_type_var1##_type_var2##_type_var3##_concept)(); \
86 template <_func##_type_var1##_type_var2##_type_var3##_concept _Tp1> \
87 struct _concept_checking##_type_var1##_type_var2##_type_var3##_concept { }; \
88 typedef _concept_checking##_type_var1##_type_var2##_type_var3##_concept< \
89 &_ns::_concept <_type_var1,_type_var2,_type_var3>::__constraints> \
90 _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_concept
92 #define _GLIBCXX_CLASS_REQUIRES4(_type_var1, _type_var2, _type_var3, _type_var4, _ns, _concept) \
93 typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::* _func##_type_var1##_type_var2##_type_var3##_type_var4##_concept)(); \
94 template <_func##_type_var1##_type_var2##_type_var3##_type_var4##_concept _Tp1> \
95 struct _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept { }; \
96 typedef _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept< \
97 &_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::__constraints> \
98 _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_type_var4##_concept
101 template <
class _Tp1,
class _Tp2>
102 struct _Aux_require_same { };
105 struct _Aux_require_same<_Tp,_Tp> {
typedef _Tp _Type; };
107 template <
class _Tp1,
class _Tp2>
108 struct _SameTypeConcept
110 void __constraints() {
111 typedef typename _Aux_require_same<_Tp1, _Tp2>::_Type _Required;
116 struct _IntegerConcept {
117 void __constraints() {
118 __error_type_must_be_an_integer_type();
121 template <>
struct _IntegerConcept<short> {
void __constraints() {} };
122 template <>
struct _IntegerConcept<unsigned short> {
void __constraints(){} };
123 template <>
struct _IntegerConcept<int> {
void __constraints() {} };
124 template <>
struct _IntegerConcept<unsigned int> {
void __constraints() {} };
125 template <>
struct _IntegerConcept<long> {
void __constraints() {} };
126 template <>
struct _IntegerConcept<unsigned long> {
void __constraints() {} };
127 template <>
struct _IntegerConcept<long long> {
void __constraints() {} };
128 template <>
struct _IntegerConcept<unsigned long long>
129 {
void __constraints() {} };
132 struct _SignedIntegerConcept {
133 void __constraints() {
134 __error_type_must_be_a_signed_integer_type();
137 template <>
struct _SignedIntegerConcept<short> {
void __constraints() {} };
138 template <>
struct _SignedIntegerConcept<int> {
void __constraints() {} };
139 template <>
struct _SignedIntegerConcept<long> {
void __constraints() {} };
140 template <>
struct _SignedIntegerConcept<long long> {
void __constraints(){}};
143 struct _UnsignedIntegerConcept {
144 void __constraints() {
145 __error_type_must_be_an_unsigned_integer_type();
148 template <>
struct _UnsignedIntegerConcept<unsigned short>
149 {
void __constraints() {} };
150 template <>
struct _UnsignedIntegerConcept<unsigned int>
151 {
void __constraints() {} };
152 template <>
struct _UnsignedIntegerConcept<unsigned long>
153 {
void __constraints() {} };
154 template <>
struct _UnsignedIntegerConcept<unsigned long long>
155 {
void __constraints() {} };
161 struct _DefaultConstructibleConcept
163 void __constraints() {
169 struct _AssignableConcept
171 void __constraints() {
173 __const_constraints(__a);
175 void __const_constraints(
const _Tp& __b) {
184 struct _CopyConstructibleConcept
186 void __constraints() {
188 _Tp* __ptr _IsUnused = &__a;
189 __const_constraints(__a);
191 void __const_constraints(
const _Tp& __a) {
192 _Tp __c _IsUnused(__a);
193 const _Tp* __ptr _IsUnused = &__a;
200 struct _SGIAssignableConcept
202 void __constraints() {
203 _Tp __b _IsUnused(__a);
205 __const_constraints(__a);
207 void __const_constraints(
const _Tp& __b) {
208 _Tp __c _IsUnused(__b);
214 template <
class _From,
class _To>
215 struct _ConvertibleConcept
217 void __constraints() {
218 _To __y _IsUnused = __x;
233 void __aux_require_boolean_expr(
const _Tp& __t) {
234 bool __x _IsUnused = __t;
239 struct _EqualityComparableConcept
241 void __constraints() {
242 __aux_require_boolean_expr(__a == __b);
248 struct _LessThanComparableConcept
250 void __constraints() {
251 __aux_require_boolean_expr(__a < __b);
258 struct _ComparableConcept
260 void __constraints() {
261 __aux_require_boolean_expr(__a < __b);
262 __aux_require_boolean_expr(__a > __b);
263 __aux_require_boolean_expr(__a <= __b);
264 __aux_require_boolean_expr(__a >= __b);
269 #define _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(_OP,_NAME) \
270 template <class _First, class _Second> \
272 void __constraints() { (void)__constraints_(); } \
273 bool __constraints_() { \
274 return __a _OP __b; \
280 #define _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(_OP,_NAME) \
281 template <class _Ret, class _First, class _Second> \
283 void __constraints() { (void)__constraints_(); } \
284 _Ret __constraints_() { \
285 return __a _OP __b; \
291 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(==, _EqualOpConcept);
292 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(!=, _NotEqualOpConcept);
293 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<, _LessThanOpConcept);
294 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<=, _LessEqualOpConcept);
295 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>, _GreaterThanOpConcept);
296 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>=, _GreaterEqualOpConcept);
298 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(+, _PlusOpConcept);
299 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(*, _TimesOpConcept);
300 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(/, _DivideOpConcept);
301 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(-, _SubtractOpConcept);
302 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(%, _ModOpConcept);
304 #undef _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT
305 #undef _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT
310 template <
class _Func,
class _Return>
311 struct _GeneratorConcept
313 void __constraints() {
314 const _Return& __r _IsUnused = __f();
320 template <
class _Func>
321 struct _GeneratorConcept<_Func,void>
323 void __constraints() {
329 template <
class _Func,
class _Return,
class _Arg>
330 struct _UnaryFunctionConcept
332 void __constraints() {
340 template <
class _Func,
class _Arg>
341 struct _UnaryFunctionConcept<_Func, void, _Arg> {
342 void __constraints() {
349 template <
class _Func,
class _Return,
class _First,
class _Second>
350 struct _BinaryFunctionConcept
352 void __constraints() {
353 __r = __f(__first, __second);
361 template <
class _Func,
class _First,
class _Second>
362 struct _BinaryFunctionConcept<_Func, void, _First, _Second>
364 void __constraints() {
365 __f(__first, __second);
372 template <
class _Func,
class _Arg>
373 struct _UnaryPredicateConcept
375 void __constraints() {
376 __aux_require_boolean_expr(__f(__arg));
382 template <
class _Func,
class _First,
class _Second>
383 struct _BinaryPredicateConcept
385 void __constraints() {
386 __aux_require_boolean_expr(__f(__a, __b));
394 template <
class _Func,
class _First,
class _Second>
395 struct _Const_BinaryPredicateConcept {
396 void __constraints() {
397 __const_constraints(__f);
399 void __const_constraints(
const _Func& __fun) {
400 __function_requires<_BinaryPredicateConcept<_Func, _First, _Second> >();
402 __aux_require_boolean_expr(__fun(__a, __b));
413 struct _TrivialIteratorConcept
415 void __constraints() {
417 __function_requires< _AssignableConcept<_Tp> >();
418 __function_requires< _EqualityComparableConcept<_Tp> >();
426 struct _Mutable_TrivialIteratorConcept
428 void __constraints() {
429 __function_requires< _TrivialIteratorConcept<_Tp> >();
436 struct _InputIteratorConcept
438 void __constraints() {
439 __function_requires< _TrivialIteratorConcept<_Tp> >();
441 typedef typename std::iterator_traits<_Tp>::difference_type _Diff;
443 typedef typename std::iterator_traits<_Tp>::reference _Ref;
444 typedef typename std::iterator_traits<_Tp>::pointer _Pt;
445 typedef typename std::iterator_traits<_Tp>::iterator_category _Cat;
446 __function_requires< _ConvertibleConcept<
447 typename std::iterator_traits<_Tp>::iterator_category,
455 template <
class _Tp,
class _ValueT>
456 struct _OutputIteratorConcept
458 void __constraints() {
459 __function_requires< _AssignableConcept<_Tp> >();
469 struct _ForwardIteratorConcept
471 void __constraints() {
472 __function_requires< _InputIteratorConcept<_Tp> >();
473 __function_requires< _DefaultConstructibleConcept<_Tp> >();
474 __function_requires< _ConvertibleConcept<
475 typename std::iterator_traits<_Tp>::iterator_category,
477 typedef typename std::iterator_traits<_Tp>::reference _Ref;
478 _Ref __r _IsUnused = *__i;
484 struct _Mutable_ForwardIteratorConcept
486 void __constraints() {
487 __function_requires< _ForwardIteratorConcept<_Tp> >();
494 struct _BidirectionalIteratorConcept
496 void __constraints() {
497 __function_requires< _ForwardIteratorConcept<_Tp> >();
498 __function_requires< _ConvertibleConcept<
499 typename std::iterator_traits<_Tp>::iterator_category,
508 struct _Mutable_BidirectionalIteratorConcept
510 void __constraints() {
511 __function_requires< _BidirectionalIteratorConcept<_Tp> >();
512 __function_requires< _Mutable_ForwardIteratorConcept<_Tp> >();
520 struct _RandomAccessIteratorConcept
522 void __constraints() {
523 __function_requires< _BidirectionalIteratorConcept<_Tp> >();
524 __function_requires< _ComparableConcept<_Tp> >();
525 __function_requires< _ConvertibleConcept<
526 typename std::iterator_traits<_Tp>::iterator_category,
529 typedef typename std::iterator_traits<_Tp>::reference _Ref;
532 __i = __i + __n; __i = __n + __i;
541 typename std::iterator_traits<_Tp>::difference_type __n;
545 struct _Mutable_RandomAccessIteratorConcept
547 void __constraints() {
548 __function_requires< _RandomAccessIteratorConcept<_Tp> >();
549 __function_requires< _Mutable_BidirectionalIteratorConcept<_Tp> >();
553 typename std::iterator_traits<_Tp>::difference_type __n;
559 template <
class _Container>
560 struct _ContainerConcept
562 typedef typename _Container::value_type _Value_type;
563 typedef typename _Container::difference_type _Difference_type;
564 typedef typename _Container::size_type _Size_type;
565 typedef typename _Container::const_reference _Const_reference;
566 typedef typename _Container::const_pointer _Const_pointer;
567 typedef typename _Container::const_iterator _Const_iterator;
569 void __constraints() {
570 __function_requires< _InputIteratorConcept<_Const_iterator> >();
571 __function_requires< _AssignableConcept<_Container> >();
572 const _Container __c;
576 __n = __c.max_size();
584 template <
class _Container>
585 struct _Mutable_ContainerConcept
587 typedef typename _Container::value_type _Value_type;
588 typedef typename _Container::reference _Reference;
589 typedef typename _Container::iterator _Iterator;
590 typedef typename _Container::pointer _Pointer;
592 void __constraints() {
593 __function_requires< _ContainerConcept<_Container> >();
594 __function_requires< _AssignableConcept<_Value_type> >();
595 __function_requires< _InputIteratorConcept<_Iterator> >();
602 _Container __c, __c2;
605 template <
class _ForwardContainer>
606 struct _ForwardContainerConcept
608 void __constraints() {
609 __function_requires< _ContainerConcept<_ForwardContainer> >();
610 typedef typename _ForwardContainer::const_iterator _Const_iterator;
611 __function_requires< _ForwardIteratorConcept<_Const_iterator> >();
615 template <
class _ForwardContainer>
616 struct _Mutable_ForwardContainerConcept
618 void __constraints() {
619 __function_requires< _ForwardContainerConcept<_ForwardContainer> >();
620 __function_requires< _Mutable_ContainerConcept<_ForwardContainer> >();
621 typedef typename _ForwardContainer::iterator _Iterator;
622 __function_requires< _Mutable_ForwardIteratorConcept<_Iterator> >();
626 template <
class _ReversibleContainer>
627 struct _ReversibleContainerConcept
629 typedef typename _ReversibleContainer::const_iterator _Const_iterator;
630 typedef typename _ReversibleContainer::const_reverse_iterator
631 _Const_reverse_iterator;
633 void __constraints() {
634 __function_requires< _ForwardContainerConcept<_ReversibleContainer> >();
635 __function_requires< _BidirectionalIteratorConcept<_Const_iterator> >();
637 _BidirectionalIteratorConcept<_Const_reverse_iterator> >();
639 const _ReversibleContainer __c;
640 _Const_reverse_iterator __i = __c.rbegin();
645 template <
class _ReversibleContainer>
646 struct _Mutable_ReversibleContainerConcept
648 typedef typename _ReversibleContainer::iterator _Iterator;
649 typedef typename _ReversibleContainer::reverse_iterator _Reverse_iterator;
651 void __constraints() {
652 __function_requires<_ReversibleContainerConcept<_ReversibleContainer> >();
654 _Mutable_ForwardContainerConcept<_ReversibleContainer> >();
655 __function_requires<_Mutable_BidirectionalIteratorConcept<_Iterator> >();
657 _Mutable_BidirectionalIteratorConcept<_Reverse_iterator> >();
659 _Reverse_iterator __i = __c.rbegin();
662 _ReversibleContainer __c;
665 template <
class _RandomAccessContainer>
666 struct _RandomAccessContainerConcept
668 typedef typename _RandomAccessContainer::size_type _Size_type;
669 typedef typename _RandomAccessContainer::const_reference _Const_reference;
670 typedef typename _RandomAccessContainer::const_iterator _Const_iterator;
671 typedef typename _RandomAccessContainer::const_reverse_iterator
672 _Const_reverse_iterator;
674 void __constraints() {
676 _ReversibleContainerConcept<_RandomAccessContainer> >();
677 __function_requires< _RandomAccessIteratorConcept<_Const_iterator> >();
679 _RandomAccessIteratorConcept<_Const_reverse_iterator> >();
681 const _RandomAccessContainer __c;
682 _Const_reference __r _IsUnused = __c[__n];
687 template <
class _RandomAccessContainer>
688 struct _Mutable_RandomAccessContainerConcept
690 typedef typename _RandomAccessContainer::size_type _Size_type;
691 typedef typename _RandomAccessContainer::reference _Reference;
692 typedef typename _RandomAccessContainer::iterator _Iterator;
693 typedef typename _RandomAccessContainer::reverse_iterator _Reverse_iterator;
695 void __constraints() {
697 _RandomAccessContainerConcept<_RandomAccessContainer> >();
699 _Mutable_ReversibleContainerConcept<_RandomAccessContainer> >();
700 __function_requires< _Mutable_RandomAccessIteratorConcept<_Iterator> >();
702 _Mutable_RandomAccessIteratorConcept<_Reverse_iterator> >();
704 _Reference __r _IsUnused = __c[__i];
707 _RandomAccessContainer __c;
711 template <
class _Sequence>
712 struct _SequenceConcept
714 typedef typename _Sequence::reference _Reference;
715 typedef typename _Sequence::const_reference _Const_reference;
717 void __constraints() {
721 __function_requires< _Mutable_ForwardContainerConcept<_Sequence> >();
722 __function_requires< _DefaultConstructibleConcept<_Sequence> >();
725 __c _IsUnused(__n, __t),
726 __c2 _IsUnused(__first, __last);
728 __c.insert(__p, __t);
729 __c.insert(__p, __n, __t);
730 __c.insert(__p, __first, __last);
735 _Reference __r _IsUnused = __c.front();
737 __const_constraints(__c);
739 void __const_constraints(
const _Sequence& __c) {
740 _Const_reference __r _IsUnused = __c.front();
742 typename _Sequence::value_type __t;
743 typename _Sequence::size_type __n;
744 typename _Sequence::value_type *__first, *__last;
745 typename _Sequence::iterator __p, __q;
748 template <
class _FrontInsertionSequence>
749 struct _FrontInsertionSequenceConcept
751 void __constraints() {
752 __function_requires< _SequenceConcept<_FrontInsertionSequence> >();
757 _FrontInsertionSequence __c;
758 typename _FrontInsertionSequence::value_type __t;
761 template <
class _BackInsertionSequence>
762 struct _BackInsertionSequenceConcept
764 typedef typename _BackInsertionSequence::reference _Reference;
765 typedef typename _BackInsertionSequence::const_reference _Const_reference;
767 void __constraints() {
768 __function_requires< _SequenceConcept<_BackInsertionSequence> >();
772 _Reference __r _IsUnused = __c.back();
774 void __const_constraints(
const _BackInsertionSequence& __c) {
775 _Const_reference __r _IsUnused = __c.back();
777 _BackInsertionSequence __c;
778 typename _BackInsertionSequence::value_type __t;
781 _GLIBCXX_END_NAMESPACE
785 #endif // _GLIBCXX_BOOST_CONCEPT_CHECK
Bidirectional iterators support a superset of forward iterator operations.
Random-access iterators support a superset of bidirectional iterator operations.
Forward iterators support a superset of input iterator operations.