39 #ifndef _BOOST_CONCEPT_CHECK_H 40 #define _BOOST_CONCEPT_CHECK_H 1 42 #pragma GCC system_header 47 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
49 _GLIBCXX_BEGIN_NAMESPACE_VERSION
51 #pragma GCC diagnostic push 52 #pragma GCC diagnostic ignored "-Wunused-local-typedefs" 54 #define _IsUnused __attribute__ ((__unused__)) 59 template <
class _Concept>
60 inline void __function_requires()
62 void (_Concept::*__x)() _IsUnused = &_Concept::__constraints;
68 void __error_type_must_be_an_integer_type();
69 void __error_type_must_be_an_unsigned_integer_type();
70 void __error_type_must_be_a_signed_integer_type();
73 #define _GLIBCXX_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 &_ns::_concept <_type_var>::__constraints> \ 79 _concept_checking_typedef##_type_var##_concept 81 #define _GLIBCXX_CLASS_REQUIRES2(_type_var1, _type_var2, _ns, _concept) \ 82 typedef void (_ns::_concept <_type_var1,_type_var2>::* _func##_type_var1##_type_var2##_concept)(); \ 83 template <_func##_type_var1##_type_var2##_concept _Tp1> \ 84 struct _concept_checking##_type_var1##_type_var2##_concept { }; \ 85 typedef _concept_checking##_type_var1##_type_var2##_concept< \ 86 &_ns::_concept <_type_var1,_type_var2>::__constraints> \ 87 _concept_checking_typedef##_type_var1##_type_var2##_concept 89 #define _GLIBCXX_CLASS_REQUIRES3(_type_var1, _type_var2, _type_var3, _ns, _concept) \ 90 typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3>::* _func##_type_var1##_type_var2##_type_var3##_concept)(); \ 91 template <_func##_type_var1##_type_var2##_type_var3##_concept _Tp1> \ 92 struct _concept_checking##_type_var1##_type_var2##_type_var3##_concept { }; \ 93 typedef _concept_checking##_type_var1##_type_var2##_type_var3##_concept< \ 94 &_ns::_concept <_type_var1,_type_var2,_type_var3>::__constraints> \ 95 _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_concept 97 #define _GLIBCXX_CLASS_REQUIRES4(_type_var1, _type_var2, _type_var3, _type_var4, _ns, _concept) \ 98 typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::* _func##_type_var1##_type_var2##_type_var3##_type_var4##_concept)(); \ 99 template <_func##_type_var1##_type_var2##_type_var3##_type_var4##_concept _Tp1> \ 100 struct _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept { }; \ 101 typedef _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept< \ 102 &_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::__constraints> \ 103 _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_type_var4##_concept 106 template <
class _Tp1,
class _Tp2>
107 struct _Aux_require_same { };
110 struct _Aux_require_same<_Tp,_Tp> {
typedef _Tp _Type; };
112 template <
class _Tp1,
class _Tp2>
113 struct _SameTypeConcept
115 void __constraints() {
116 typedef typename _Aux_require_same<_Tp1, _Tp2>::_Type _Required;
121 struct _IntegerConcept {
122 void __constraints() {
123 __error_type_must_be_an_integer_type();
126 template <>
struct _IntegerConcept<short> {
void __constraints() {} };
127 template <>
struct _IntegerConcept<unsigned short> {
void __constraints(){} };
128 template <>
struct _IntegerConcept<int> {
void __constraints() {} };
129 template <>
struct _IntegerConcept<unsigned int> {
void __constraints() {} };
130 template <>
struct _IntegerConcept<long> {
void __constraints() {} };
131 template <>
struct _IntegerConcept<unsigned long> {
void __constraints() {} };
132 template <>
struct _IntegerConcept<long long> {
void __constraints() {} };
133 template <>
struct _IntegerConcept<unsigned long long>
134 {
void __constraints() {} };
137 struct _SignedIntegerConcept {
138 void __constraints() {
139 __error_type_must_be_a_signed_integer_type();
142 template <>
struct _SignedIntegerConcept<short> {
void __constraints() {} };
143 template <>
struct _SignedIntegerConcept<int> {
void __constraints() {} };
144 template <>
struct _SignedIntegerConcept<long> {
void __constraints() {} };
145 template <>
struct _SignedIntegerConcept<long long> {
void __constraints(){}};
148 struct _UnsignedIntegerConcept {
149 void __constraints() {
150 __error_type_must_be_an_unsigned_integer_type();
153 template <>
struct _UnsignedIntegerConcept<unsigned short>
154 {
void __constraints() {} };
155 template <>
struct _UnsignedIntegerConcept<unsigned int>
156 {
void __constraints() {} };
157 template <>
struct _UnsignedIntegerConcept<unsigned long>
158 {
void __constraints() {} };
159 template <>
struct _UnsignedIntegerConcept<unsigned long long>
160 {
void __constraints() {} };
166 struct _DefaultConstructibleConcept
168 void __constraints() {
174 struct _AssignableConcept
176 void __constraints() {
178 __const_constraints(__a);
180 void __const_constraints(
const _Tp& __b) {
189 struct _CopyConstructibleConcept
191 void __constraints() {
193 _Tp* __ptr _IsUnused = &__a;
194 __const_constraints(__a);
196 void __const_constraints(
const _Tp& __a) {
197 _Tp __c _IsUnused(__a);
198 const _Tp* __ptr _IsUnused = &__a;
205 struct _SGIAssignableConcept
207 void __constraints() {
208 _Tp __b _IsUnused(__a);
210 __const_constraints(__a);
212 void __const_constraints(
const _Tp& __b) {
213 _Tp __c _IsUnused(__b);
219 template <
class _From,
class _To>
220 struct _ConvertibleConcept
222 void __constraints() {
223 _To __y _IsUnused = __x;
238 void __aux_require_boolean_expr(
const _Tp& __t) {
239 bool __x _IsUnused = __t;
244 struct _EqualityComparableConcept
246 void __constraints() {
247 __aux_require_boolean_expr(__a == __b);
253 struct _LessThanComparableConcept
255 void __constraints() {
256 __aux_require_boolean_expr(__a < __b);
263 struct _ComparableConcept
265 void __constraints() {
266 __aux_require_boolean_expr(__a < __b);
267 __aux_require_boolean_expr(__a > __b);
268 __aux_require_boolean_expr(__a <= __b);
269 __aux_require_boolean_expr(__a >= __b);
274 #define _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(_OP,_NAME) \ 275 template <class _First, class _Second> \ 277 void __constraints() { (void)__constraints_(); } \ 278 bool __constraints_() { \ 279 return __a _OP __b; \ 285 #define _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(_OP,_NAME) \ 286 template <class _Ret, class _First, class _Second> \ 288 void __constraints() { (void)__constraints_(); } \ 289 _Ret __constraints_() { \ 290 return __a _OP __b; \ 296 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(==, _EqualOpConcept);
297 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(!=, _NotEqualOpConcept);
298 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<, _LessThanOpConcept);
299 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<=, _LessEqualOpConcept);
300 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>, _GreaterThanOpConcept);
301 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>=, _GreaterEqualOpConcept);
303 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(+, _PlusOpConcept);
304 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(*, _TimesOpConcept);
305 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(/, _DivideOpConcept);
306 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(-, _SubtractOpConcept);
307 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(%, _ModOpConcept);
309 #undef _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT 310 #undef _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT 315 template <
class _Func,
class _Return>
316 struct _GeneratorConcept
318 void __constraints() {
319 const _Return& __r _IsUnused = __f();
325 template <
class _Func>
326 struct _GeneratorConcept<_Func,void>
328 void __constraints() {
334 template <
class _Func,
class _Return,
class _Arg>
335 struct _UnaryFunctionConcept
337 void __constraints() {
345 template <
class _Func,
class _Arg>
346 struct _UnaryFunctionConcept<_Func, void, _Arg> {
347 void __constraints() {
354 template <
class _Func,
class _Return,
class _First,
class _Second>
355 struct _BinaryFunctionConcept
357 void __constraints() {
358 __r = __f(__first, __second);
366 template <
class _Func,
class _First,
class _Second>
367 struct _BinaryFunctionConcept<_Func, void, _First, _Second>
369 void __constraints() {
370 __f(__first, __second);
377 template <
class _Func,
class _Arg>
378 struct _UnaryPredicateConcept
380 void __constraints() {
381 __aux_require_boolean_expr(__f(__arg));
387 template <
class _Func,
class _First,
class _Second>
388 struct _BinaryPredicateConcept
390 void __constraints() {
391 __aux_require_boolean_expr(__f(__a, __b));
399 template <
class _Func,
class _First,
class _Second>
400 struct _Const_BinaryPredicateConcept {
401 void __constraints() {
402 __const_constraints(__f);
404 void __const_constraints(
const _Func& __fun) {
405 __function_requires<_BinaryPredicateConcept<_Func, _First, _Second> >();
407 __aux_require_boolean_expr(__fun(__a, __b));
418 struct _TrivialIteratorConcept
420 void __constraints() {
422 __function_requires< _AssignableConcept<_Tp> >();
423 __function_requires< _EqualityComparableConcept<_Tp> >();
431 struct _Mutable_TrivialIteratorConcept
433 void __constraints() {
434 __function_requires< _TrivialIteratorConcept<_Tp> >();
441 struct _InputIteratorConcept
443 void __constraints() {
444 __function_requires< _TrivialIteratorConcept<_Tp> >();
446 typedef typename std::iterator_traits<_Tp>::difference_type _Diff;
448 typedef typename std::iterator_traits<_Tp>::reference _Ref;
449 typedef typename std::iterator_traits<_Tp>::pointer _Pt;
450 typedef typename std::iterator_traits<_Tp>::iterator_category _Cat;
451 __function_requires< _ConvertibleConcept<
452 typename std::iterator_traits<_Tp>::iterator_category,
460 template <
class _Tp,
class _ValueT>
461 struct _OutputIteratorConcept
463 void __constraints() {
464 __function_requires< _AssignableConcept<_Tp> >();
474 struct _ForwardIteratorConcept
476 void __constraints() {
477 __function_requires< _InputIteratorConcept<_Tp> >();
478 __function_requires< _DefaultConstructibleConcept<_Tp> >();
479 __function_requires< _ConvertibleConcept<
480 typename std::iterator_traits<_Tp>::iterator_category,
482 typedef typename std::iterator_traits<_Tp>::reference _Ref;
483 _Ref __r _IsUnused = *__i;
489 struct _Mutable_ForwardIteratorConcept
491 void __constraints() {
492 __function_requires< _ForwardIteratorConcept<_Tp> >();
499 struct _BidirectionalIteratorConcept
501 void __constraints() {
502 __function_requires< _ForwardIteratorConcept<_Tp> >();
503 __function_requires< _ConvertibleConcept<
504 typename std::iterator_traits<_Tp>::iterator_category,
513 struct _Mutable_BidirectionalIteratorConcept
515 void __constraints() {
516 __function_requires< _BidirectionalIteratorConcept<_Tp> >();
517 __function_requires< _Mutable_ForwardIteratorConcept<_Tp> >();
525 struct _RandomAccessIteratorConcept
527 void __constraints() {
528 __function_requires< _BidirectionalIteratorConcept<_Tp> >();
529 __function_requires< _ComparableConcept<_Tp> >();
530 __function_requires< _ConvertibleConcept<
531 typename std::iterator_traits<_Tp>::iterator_category,
534 typedef typename std::iterator_traits<_Tp>::reference _Ref;
537 __i = __i + __n; __i = __n + __i;
546 typename std::iterator_traits<_Tp>::difference_type __n;
550 struct _Mutable_RandomAccessIteratorConcept
552 void __constraints() {
553 __function_requires< _RandomAccessIteratorConcept<_Tp> >();
554 __function_requires< _Mutable_BidirectionalIteratorConcept<_Tp> >();
558 typename std::iterator_traits<_Tp>::difference_type __n;
564 template <
class _Container>
565 struct _ContainerConcept
567 typedef typename _Container::value_type _Value_type;
568 typedef typename _Container::difference_type _Difference_type;
569 typedef typename _Container::size_type _Size_type;
570 typedef typename _Container::const_reference _Const_reference;
571 typedef typename _Container::const_pointer _Const_pointer;
572 typedef typename _Container::const_iterator _Const_iterator;
574 void __constraints() {
575 __function_requires< _InputIteratorConcept<_Const_iterator> >();
576 __function_requires< _AssignableConcept<_Container> >();
577 const _Container __c;
581 __n = __c.max_size();
589 template <
class _Container>
590 struct _Mutable_ContainerConcept
592 typedef typename _Container::value_type _Value_type;
593 typedef typename _Container::reference _Reference;
594 typedef typename _Container::iterator _Iterator;
595 typedef typename _Container::pointer _Pointer;
597 void __constraints() {
598 __function_requires< _ContainerConcept<_Container> >();
599 __function_requires< _AssignableConcept<_Value_type> >();
600 __function_requires< _InputIteratorConcept<_Iterator> >();
607 _Container __c, __c2;
610 template <
class _ForwardContainer>
611 struct _ForwardContainerConcept
613 void __constraints() {
614 __function_requires< _ContainerConcept<_ForwardContainer> >();
615 typedef typename _ForwardContainer::const_iterator _Const_iterator;
616 __function_requires< _ForwardIteratorConcept<_Const_iterator> >();
620 template <
class _ForwardContainer>
621 struct _Mutable_ForwardContainerConcept
623 void __constraints() {
624 __function_requires< _ForwardContainerConcept<_ForwardContainer> >();
625 __function_requires< _Mutable_ContainerConcept<_ForwardContainer> >();
626 typedef typename _ForwardContainer::iterator _Iterator;
627 __function_requires< _Mutable_ForwardIteratorConcept<_Iterator> >();
631 template <
class _ReversibleContainer>
632 struct _ReversibleContainerConcept
634 typedef typename _ReversibleContainer::const_iterator _Const_iterator;
635 typedef typename _ReversibleContainer::const_reverse_iterator
636 _Const_reverse_iterator;
638 void __constraints() {
639 __function_requires< _ForwardContainerConcept<_ReversibleContainer> >();
640 __function_requires< _BidirectionalIteratorConcept<_Const_iterator> >();
642 _BidirectionalIteratorConcept<_Const_reverse_iterator> >();
644 const _ReversibleContainer __c;
645 _Const_reverse_iterator __i = __c.rbegin();
650 template <
class _ReversibleContainer>
651 struct _Mutable_ReversibleContainerConcept
653 typedef typename _ReversibleContainer::iterator _Iterator;
654 typedef typename _ReversibleContainer::reverse_iterator _Reverse_iterator;
656 void __constraints() {
657 __function_requires<_ReversibleContainerConcept<_ReversibleContainer> >();
659 _Mutable_ForwardContainerConcept<_ReversibleContainer> >();
660 __function_requires<_Mutable_BidirectionalIteratorConcept<_Iterator> >();
662 _Mutable_BidirectionalIteratorConcept<_Reverse_iterator> >();
664 _Reverse_iterator __i = __c.rbegin();
667 _ReversibleContainer __c;
670 template <
class _RandomAccessContainer>
671 struct _RandomAccessContainerConcept
673 typedef typename _RandomAccessContainer::size_type _Size_type;
674 typedef typename _RandomAccessContainer::const_reference _Const_reference;
675 typedef typename _RandomAccessContainer::const_iterator _Const_iterator;
676 typedef typename _RandomAccessContainer::const_reverse_iterator
677 _Const_reverse_iterator;
679 void __constraints() {
681 _ReversibleContainerConcept<_RandomAccessContainer> >();
682 __function_requires< _RandomAccessIteratorConcept<_Const_iterator> >();
684 _RandomAccessIteratorConcept<_Const_reverse_iterator> >();
686 const _RandomAccessContainer __c;
687 _Const_reference __r _IsUnused = __c[__n];
692 template <
class _RandomAccessContainer>
693 struct _Mutable_RandomAccessContainerConcept
695 typedef typename _RandomAccessContainer::size_type _Size_type;
696 typedef typename _RandomAccessContainer::reference _Reference;
697 typedef typename _RandomAccessContainer::iterator _Iterator;
698 typedef typename _RandomAccessContainer::reverse_iterator _Reverse_iterator;
700 void __constraints() {
702 _RandomAccessContainerConcept<_RandomAccessContainer> >();
704 _Mutable_ReversibleContainerConcept<_RandomAccessContainer> >();
705 __function_requires< _Mutable_RandomAccessIteratorConcept<_Iterator> >();
707 _Mutable_RandomAccessIteratorConcept<_Reverse_iterator> >();
709 _Reference __r _IsUnused = __c[__i];
712 _RandomAccessContainer __c;
716 template <
class _Sequence>
717 struct _SequenceConcept
719 typedef typename _Sequence::reference _Reference;
720 typedef typename _Sequence::const_reference _Const_reference;
722 void __constraints() {
726 __function_requires< _Mutable_ForwardContainerConcept<_Sequence> >();
727 __function_requires< _DefaultConstructibleConcept<_Sequence> >();
730 __c _IsUnused(__n, __t),
731 __c2 _IsUnused(__first, __last);
733 __c.insert(__p, __t);
734 __c.insert(__p, __n, __t);
735 __c.insert(__p, __first, __last);
740 _Reference __r _IsUnused = __c.front();
742 __const_constraints(__c);
744 void __const_constraints(
const _Sequence& __c) {
745 _Const_reference __r _IsUnused = __c.front();
747 typename _Sequence::value_type __t;
748 typename _Sequence::size_type __n;
749 typename _Sequence::value_type *__first, *__last;
750 typename _Sequence::iterator __p, __q;
753 template <
class _FrontInsertionSequence>
754 struct _FrontInsertionSequenceConcept
756 void __constraints() {
757 __function_requires< _SequenceConcept<_FrontInsertionSequence> >();
762 _FrontInsertionSequence __c;
763 typename _FrontInsertionSequence::value_type __t;
766 template <
class _BackInsertionSequence>
767 struct _BackInsertionSequenceConcept
769 typedef typename _BackInsertionSequence::reference _Reference;
770 typedef typename _BackInsertionSequence::const_reference _Const_reference;
772 void __constraints() {
773 __function_requires< _SequenceConcept<_BackInsertionSequence> >();
777 _Reference __r _IsUnused = __c.back();
779 void __const_constraints(
const _BackInsertionSequence& __c) {
780 _Const_reference __r _IsUnused = __c.back();
782 _BackInsertionSequence __c;
783 typename _BackInsertionSequence::value_type __t;
786 _GLIBCXX_END_NAMESPACE_VERSION
789 #pragma GCC diagnostic pop 792 #endif // _GLIBCXX_BOOST_CONCEPT_CHECK Bidirectional iterators support a superset of forward iterator operations.
Forward iterators support a superset of input iterator operations.
GNU extensions for public use.
Random-access iterators support a superset of bidirectional iterator operations.