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 #define _IsUnused __attribute__ ((__unused__))
56 template <
class _Concept>
57 inline void __function_requires()
59 void (_Concept::*__x)() _IsUnused = &_Concept::__constraints;
65 void __error_type_must_be_an_integer_type();
66 void __error_type_must_be_an_unsigned_integer_type();
67 void __error_type_must_be_a_signed_integer_type();
70 #define _GLIBCXX_CLASS_REQUIRES(_type_var, _ns, _concept) \
71 typedef void (_ns::_concept <_type_var>::* _func##_type_var##_concept)(); \
72 template <_func##_type_var##_concept _Tp1> \
73 struct _concept_checking##_type_var##_concept { }; \
74 typedef _concept_checking##_type_var##_concept< \
75 &_ns::_concept <_type_var>::__constraints> \
76 _concept_checking_typedef##_type_var##_concept
78 #define _GLIBCXX_CLASS_REQUIRES2(_type_var1, _type_var2, _ns, _concept) \
79 typedef void (_ns::_concept <_type_var1,_type_var2>::* _func##_type_var1##_type_var2##_concept)(); \
80 template <_func##_type_var1##_type_var2##_concept _Tp1> \
81 struct _concept_checking##_type_var1##_type_var2##_concept { }; \
82 typedef _concept_checking##_type_var1##_type_var2##_concept< \
83 &_ns::_concept <_type_var1,_type_var2>::__constraints> \
84 _concept_checking_typedef##_type_var1##_type_var2##_concept
86 #define _GLIBCXX_CLASS_REQUIRES3(_type_var1, _type_var2, _type_var3, _ns, _concept) \
87 typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3>::* _func##_type_var1##_type_var2##_type_var3##_concept)(); \
88 template <_func##_type_var1##_type_var2##_type_var3##_concept _Tp1> \
89 struct _concept_checking##_type_var1##_type_var2##_type_var3##_concept { }; \
90 typedef _concept_checking##_type_var1##_type_var2##_type_var3##_concept< \
91 &_ns::_concept <_type_var1,_type_var2,_type_var3>::__constraints> \
92 _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_concept
94 #define _GLIBCXX_CLASS_REQUIRES4(_type_var1, _type_var2, _type_var3, _type_var4, _ns, _concept) \
95 typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::* _func##_type_var1##_type_var2##_type_var3##_type_var4##_concept)(); \
96 template <_func##_type_var1##_type_var2##_type_var3##_type_var4##_concept _Tp1> \
97 struct _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept { }; \
98 typedef _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept< \
99 &_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::__constraints> \
100 _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_type_var4##_concept
103 template <
class _Tp1,
class _Tp2>
104 struct _Aux_require_same { };
107 struct _Aux_require_same<_Tp,_Tp> {
typedef _Tp _Type; };
109 template <
class _Tp1,
class _Tp2>
110 struct _SameTypeConcept
112 void __constraints() {
113 typedef typename _Aux_require_same<_Tp1, _Tp2>::_Type _Required;
118 struct _IntegerConcept {
119 void __constraints() {
120 __error_type_must_be_an_integer_type();
123 template <>
struct _IntegerConcept<short> {
void __constraints() {} };
124 template <>
struct _IntegerConcept<unsigned short> {
void __constraints(){} };
125 template <>
struct _IntegerConcept<int> {
void __constraints() {} };
126 template <>
struct _IntegerConcept<unsigned int> {
void __constraints() {} };
127 template <>
struct _IntegerConcept<long> {
void __constraints() {} };
128 template <>
struct _IntegerConcept<unsigned long> {
void __constraints() {} };
129 template <>
struct _IntegerConcept<long long> {
void __constraints() {} };
130 template <>
struct _IntegerConcept<unsigned long long>
131 {
void __constraints() {} };
134 struct _SignedIntegerConcept {
135 void __constraints() {
136 __error_type_must_be_a_signed_integer_type();
139 template <>
struct _SignedIntegerConcept<short> {
void __constraints() {} };
140 template <>
struct _SignedIntegerConcept<int> {
void __constraints() {} };
141 template <>
struct _SignedIntegerConcept<long> {
void __constraints() {} };
142 template <>
struct _SignedIntegerConcept<long long> {
void __constraints(){}};
145 struct _UnsignedIntegerConcept {
146 void __constraints() {
147 __error_type_must_be_an_unsigned_integer_type();
150 template <>
struct _UnsignedIntegerConcept<unsigned short>
151 {
void __constraints() {} };
152 template <>
struct _UnsignedIntegerConcept<unsigned int>
153 {
void __constraints() {} };
154 template <>
struct _UnsignedIntegerConcept<unsigned long>
155 {
void __constraints() {} };
156 template <>
struct _UnsignedIntegerConcept<unsigned long long>
157 {
void __constraints() {} };
163 struct _DefaultConstructibleConcept
165 void __constraints() {
171 struct _AssignableConcept
173 void __constraints() {
175 __const_constraints(__a);
177 void __const_constraints(
const _Tp& __b) {
186 struct _CopyConstructibleConcept
188 void __constraints() {
190 _Tp* __ptr _IsUnused = &__a;
191 __const_constraints(__a);
193 void __const_constraints(
const _Tp& __a) {
194 _Tp __c _IsUnused(__a);
195 const _Tp* __ptr _IsUnused = &__a;
202 struct _SGIAssignableConcept
204 void __constraints() {
205 _Tp __b _IsUnused(__a);
207 __const_constraints(__a);
209 void __const_constraints(
const _Tp& __b) {
210 _Tp __c _IsUnused(__b);
216 template <
class _From,
class _To>
217 struct _ConvertibleConcept
219 void __constraints() {
220 _To __y _IsUnused = __x;
235 void __aux_require_boolean_expr(
const _Tp& __t) {
236 bool __x _IsUnused = __t;
241 struct _EqualityComparableConcept
243 void __constraints() {
244 __aux_require_boolean_expr(__a == __b);
250 struct _LessThanComparableConcept
252 void __constraints() {
253 __aux_require_boolean_expr(__a < __b);
260 struct _ComparableConcept
262 void __constraints() {
263 __aux_require_boolean_expr(__a < __b);
264 __aux_require_boolean_expr(__a > __b);
265 __aux_require_boolean_expr(__a <= __b);
266 __aux_require_boolean_expr(__a >= __b);
271 #define _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(_OP,_NAME) \
272 template <class _First, class _Second> \
274 void __constraints() { (void)__constraints_(); } \
275 bool __constraints_() { \
276 return __a _OP __b; \
282 #define _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(_OP,_NAME) \
283 template <class _Ret, class _First, class _Second> \
285 void __constraints() { (void)__constraints_(); } \
286 _Ret __constraints_() { \
287 return __a _OP __b; \
293 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(==, _EqualOpConcept);
294 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(!=, _NotEqualOpConcept);
295 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<, _LessThanOpConcept);
296 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<=, _LessEqualOpConcept);
297 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>, _GreaterThanOpConcept);
298 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>=, _GreaterEqualOpConcept);
300 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(+, _PlusOpConcept);
301 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(*, _TimesOpConcept);
302 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(/, _DivideOpConcept);
303 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(-, _SubtractOpConcept);
304 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(%, _ModOpConcept);
306 #undef _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT
307 #undef _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT
312 template <
class _Func,
class _Return>
313 struct _GeneratorConcept
315 void __constraints() {
316 const _Return& __r _IsUnused = __f();
322 template <
class _Func>
323 struct _GeneratorConcept<_Func,void>
325 void __constraints() {
331 template <
class _Func,
class _Return,
class _Arg>
332 struct _UnaryFunctionConcept
334 void __constraints() {
342 template <
class _Func,
class _Arg>
343 struct _UnaryFunctionConcept<_Func, void, _Arg> {
344 void __constraints() {
351 template <
class _Func,
class _Return,
class _First,
class _Second>
352 struct _BinaryFunctionConcept
354 void __constraints() {
355 __r = __f(__first, __second);
363 template <
class _Func,
class _First,
class _Second>
364 struct _BinaryFunctionConcept<_Func, void, _First, _Second>
366 void __constraints() {
367 __f(__first, __second);
374 template <
class _Func,
class _Arg>
375 struct _UnaryPredicateConcept
377 void __constraints() {
378 __aux_require_boolean_expr(__f(__arg));
384 template <
class _Func,
class _First,
class _Second>
385 struct _BinaryPredicateConcept
387 void __constraints() {
388 __aux_require_boolean_expr(__f(__a, __b));
396 template <
class _Func,
class _First,
class _Second>
397 struct _Const_BinaryPredicateConcept {
398 void __constraints() {
399 __const_constraints(__f);
401 void __const_constraints(
const _Func& __fun) {
402 __function_requires<_BinaryPredicateConcept<_Func, _First, _Second> >();
404 __aux_require_boolean_expr(__fun(__a, __b));
415 struct _TrivialIteratorConcept
417 void __constraints() {
419 __function_requires< _AssignableConcept<_Tp> >();
420 __function_requires< _EqualityComparableConcept<_Tp> >();
428 struct _Mutable_TrivialIteratorConcept
430 void __constraints() {
431 __function_requires< _TrivialIteratorConcept<_Tp> >();
438 struct _InputIteratorConcept
440 void __constraints() {
441 __function_requires< _TrivialIteratorConcept<_Tp> >();
443 typedef typename std::iterator_traits<_Tp>::difference_type _Diff;
445 typedef typename std::iterator_traits<_Tp>::reference _Ref;
446 typedef typename std::iterator_traits<_Tp>::pointer _Pt;
447 typedef typename std::iterator_traits<_Tp>::iterator_category _Cat;
448 __function_requires< _ConvertibleConcept<
449 typename std::iterator_traits<_Tp>::iterator_category,
457 template <
class _Tp,
class _ValueT>
458 struct _OutputIteratorConcept
460 void __constraints() {
461 __function_requires< _AssignableConcept<_Tp> >();
471 struct _ForwardIteratorConcept
473 void __constraints() {
474 __function_requires< _InputIteratorConcept<_Tp> >();
475 __function_requires< _DefaultConstructibleConcept<_Tp> >();
476 __function_requires< _ConvertibleConcept<
477 typename std::iterator_traits<_Tp>::iterator_category,
479 typedef typename std::iterator_traits<_Tp>::reference _Ref;
480 _Ref __r _IsUnused = *__i;
486 struct _Mutable_ForwardIteratorConcept
488 void __constraints() {
489 __function_requires< _ForwardIteratorConcept<_Tp> >();
496 struct _BidirectionalIteratorConcept
498 void __constraints() {
499 __function_requires< _ForwardIteratorConcept<_Tp> >();
500 __function_requires< _ConvertibleConcept<
501 typename std::iterator_traits<_Tp>::iterator_category,
510 struct _Mutable_BidirectionalIteratorConcept
512 void __constraints() {
513 __function_requires< _BidirectionalIteratorConcept<_Tp> >();
514 __function_requires< _Mutable_ForwardIteratorConcept<_Tp> >();
522 struct _RandomAccessIteratorConcept
524 void __constraints() {
525 __function_requires< _BidirectionalIteratorConcept<_Tp> >();
526 __function_requires< _ComparableConcept<_Tp> >();
527 __function_requires< _ConvertibleConcept<
528 typename std::iterator_traits<_Tp>::iterator_category,
531 typedef typename std::iterator_traits<_Tp>::reference _Ref;
534 __i = __i + __n; __i = __n + __i;
543 typename std::iterator_traits<_Tp>::difference_type __n;
547 struct _Mutable_RandomAccessIteratorConcept
549 void __constraints() {
550 __function_requires< _RandomAccessIteratorConcept<_Tp> >();
551 __function_requires< _Mutable_BidirectionalIteratorConcept<_Tp> >();
555 typename std::iterator_traits<_Tp>::difference_type __n;
561 template <
class _Container>
562 struct _ContainerConcept
564 typedef typename _Container::value_type _Value_type;
565 typedef typename _Container::difference_type _Difference_type;
566 typedef typename _Container::size_type _Size_type;
567 typedef typename _Container::const_reference _Const_reference;
568 typedef typename _Container::const_pointer _Const_pointer;
569 typedef typename _Container::const_iterator _Const_iterator;
571 void __constraints() {
572 __function_requires< _InputIteratorConcept<_Const_iterator> >();
573 __function_requires< _AssignableConcept<_Container> >();
574 const _Container __c;
578 __n = __c.max_size();
586 template <
class _Container>
587 struct _Mutable_ContainerConcept
589 typedef typename _Container::value_type _Value_type;
590 typedef typename _Container::reference _Reference;
591 typedef typename _Container::iterator _Iterator;
592 typedef typename _Container::pointer _Pointer;
594 void __constraints() {
595 __function_requires< _ContainerConcept<_Container> >();
596 __function_requires< _AssignableConcept<_Value_type> >();
597 __function_requires< _InputIteratorConcept<_Iterator> >();
604 _Container __c, __c2;
607 template <
class _ForwardContainer>
608 struct _ForwardContainerConcept
610 void __constraints() {
611 __function_requires< _ContainerConcept<_ForwardContainer> >();
612 typedef typename _ForwardContainer::const_iterator _Const_iterator;
613 __function_requires< _ForwardIteratorConcept<_Const_iterator> >();
617 template <
class _ForwardContainer>
618 struct _Mutable_ForwardContainerConcept
620 void __constraints() {
621 __function_requires< _ForwardContainerConcept<_ForwardContainer> >();
622 __function_requires< _Mutable_ContainerConcept<_ForwardContainer> >();
623 typedef typename _ForwardContainer::iterator _Iterator;
624 __function_requires< _Mutable_ForwardIteratorConcept<_Iterator> >();
628 template <
class _ReversibleContainer>
629 struct _ReversibleContainerConcept
631 typedef typename _ReversibleContainer::const_iterator _Const_iterator;
632 typedef typename _ReversibleContainer::const_reverse_iterator
633 _Const_reverse_iterator;
635 void __constraints() {
636 __function_requires< _ForwardContainerConcept<_ReversibleContainer> >();
637 __function_requires< _BidirectionalIteratorConcept<_Const_iterator> >();
639 _BidirectionalIteratorConcept<_Const_reverse_iterator> >();
641 const _ReversibleContainer __c;
642 _Const_reverse_iterator __i = __c.rbegin();
647 template <
class _ReversibleContainer>
648 struct _Mutable_ReversibleContainerConcept
650 typedef typename _ReversibleContainer::iterator _Iterator;
651 typedef typename _ReversibleContainer::reverse_iterator _Reverse_iterator;
653 void __constraints() {
654 __function_requires<_ReversibleContainerConcept<_ReversibleContainer> >();
656 _Mutable_ForwardContainerConcept<_ReversibleContainer> >();
657 __function_requires<_Mutable_BidirectionalIteratorConcept<_Iterator> >();
659 _Mutable_BidirectionalIteratorConcept<_Reverse_iterator> >();
661 _Reverse_iterator __i = __c.rbegin();
664 _ReversibleContainer __c;
667 template <
class _RandomAccessContainer>
668 struct _RandomAccessContainerConcept
670 typedef typename _RandomAccessContainer::size_type _Size_type;
671 typedef typename _RandomAccessContainer::const_reference _Const_reference;
672 typedef typename _RandomAccessContainer::const_iterator _Const_iterator;
673 typedef typename _RandomAccessContainer::const_reverse_iterator
674 _Const_reverse_iterator;
676 void __constraints() {
678 _ReversibleContainerConcept<_RandomAccessContainer> >();
679 __function_requires< _RandomAccessIteratorConcept<_Const_iterator> >();
681 _RandomAccessIteratorConcept<_Const_reverse_iterator> >();
683 const _RandomAccessContainer __c;
684 _Const_reference __r _IsUnused = __c[__n];
689 template <
class _RandomAccessContainer>
690 struct _Mutable_RandomAccessContainerConcept
692 typedef typename _RandomAccessContainer::size_type _Size_type;
693 typedef typename _RandomAccessContainer::reference _Reference;
694 typedef typename _RandomAccessContainer::iterator _Iterator;
695 typedef typename _RandomAccessContainer::reverse_iterator _Reverse_iterator;
697 void __constraints() {
699 _RandomAccessContainerConcept<_RandomAccessContainer> >();
701 _Mutable_ReversibleContainerConcept<_RandomAccessContainer> >();
702 __function_requires< _Mutable_RandomAccessIteratorConcept<_Iterator> >();
704 _Mutable_RandomAccessIteratorConcept<_Reverse_iterator> >();
706 _Reference __r _IsUnused = __c[__i];
709 _RandomAccessContainer __c;
713 template <
class _Sequence>
714 struct _SequenceConcept
716 typedef typename _Sequence::reference _Reference;
717 typedef typename _Sequence::const_reference _Const_reference;
719 void __constraints() {
723 __function_requires< _Mutable_ForwardContainerConcept<_Sequence> >();
724 __function_requires< _DefaultConstructibleConcept<_Sequence> >();
727 __c _IsUnused(__n, __t),
728 __c2 _IsUnused(__first, __last);
730 __c.insert(__p, __t);
731 __c.insert(__p, __n, __t);
732 __c.insert(__p, __first, __last);
737 _Reference __r _IsUnused = __c.front();
739 __const_constraints(__c);
741 void __const_constraints(
const _Sequence& __c) {
742 _Const_reference __r _IsUnused = __c.front();
744 typename _Sequence::value_type __t;
745 typename _Sequence::size_type __n;
746 typename _Sequence::value_type *__first, *__last;
747 typename _Sequence::iterator __p, __q;
750 template <
class _FrontInsertionSequence>
751 struct _FrontInsertionSequenceConcept
753 void __constraints() {
754 __function_requires< _SequenceConcept<_FrontInsertionSequence> >();
759 _FrontInsertionSequence __c;
760 typename _FrontInsertionSequence::value_type __t;
763 template <
class _BackInsertionSequence>
764 struct _BackInsertionSequenceConcept
766 typedef typename _BackInsertionSequence::reference _Reference;
767 typedef typename _BackInsertionSequence::const_reference _Const_reference;
769 void __constraints() {
770 __function_requires< _SequenceConcept<_BackInsertionSequence> >();
774 _Reference __r _IsUnused = __c.back();
776 void __const_constraints(
const _BackInsertionSequence& __c) {
777 _Const_reference __r _IsUnused = __c.back();
779 _BackInsertionSequence __c;
780 typename _BackInsertionSequence::value_type __t;
783 _GLIBCXX_END_NAMESPACE_VERSION
788 #endif // _GLIBCXX_BOOST_CONCEPT_CHECK
GNU extensions for public use.
Random-access iterators support a superset of bidirectional iterator operations.
Forward iterators support a superset of input iterator operations.
Bidirectional iterators support a superset of forward iterator operations.