39 #ifndef _BOOST_CONCEPT_CHECK_H
40 #define _BOOST_CONCEPT_CHECK_H 1
42 #pragma GCC system_header
47 namespace std _GLIBCXX_VISIBILITY(default)
49 _GLIBCXX_BEGIN_NAMESPACE_VERSION
50 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
52 struct _Bit_const_iterator;
53 _GLIBCXX_END_NAMESPACE_CONTAINER
54 _GLIBCXX_END_NAMESPACE_VERSION
59 template<
typename _Iterator,
typename _Sequence,
typename _Category>
63 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
65 _GLIBCXX_BEGIN_NAMESPACE_VERSION
67 #pragma GCC diagnostic push
68 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
70 #define _IsUnused __attribute__ ((__unused__))
75 template <
class _Concept>
76 _GLIBCXX14_CONSTEXPR
inline void __function_requires()
78 void (_Concept::*__x)() _IsUnused = &_Concept::__constraints;
84 void __error_type_must_be_an_integer_type();
85 void __error_type_must_be_an_unsigned_integer_type();
86 void __error_type_must_be_a_signed_integer_type();
89 #define _GLIBCXX_CLASS_REQUIRES(_type_var, _ns, _concept) \
90 typedef void (_ns::_concept <_type_var>::* _func##_type_var##_concept)(); \
91 template <_func##_type_var##_concept _Tp1> \
92 struct _concept_checking##_type_var##_concept { }; \
93 typedef _concept_checking##_type_var##_concept< \
94 &_ns::_concept <_type_var>::__constraints> \
95 _concept_checking_typedef##_type_var##_concept
97 #define _GLIBCXX_CLASS_REQUIRES2(_type_var1, _type_var2, _ns, _concept) \
98 typedef void (_ns::_concept <_type_var1,_type_var2>::* _func##_type_var1##_type_var2##_concept)(); \
99 template <_func##_type_var1##_type_var2##_concept _Tp1> \
100 struct _concept_checking##_type_var1##_type_var2##_concept { }; \
101 typedef _concept_checking##_type_var1##_type_var2##_concept< \
102 &_ns::_concept <_type_var1,_type_var2>::__constraints> \
103 _concept_checking_typedef##_type_var1##_type_var2##_concept
105 #define _GLIBCXX_CLASS_REQUIRES3(_type_var1, _type_var2, _type_var3, _ns, _concept) \
106 typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3>::* _func##_type_var1##_type_var2##_type_var3##_concept)(); \
107 template <_func##_type_var1##_type_var2##_type_var3##_concept _Tp1> \
108 struct _concept_checking##_type_var1##_type_var2##_type_var3##_concept { }; \
109 typedef _concept_checking##_type_var1##_type_var2##_type_var3##_concept< \
110 &_ns::_concept <_type_var1,_type_var2,_type_var3>::__constraints> \
111 _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_concept
113 #define _GLIBCXX_CLASS_REQUIRES4(_type_var1, _type_var2, _type_var3, _type_var4, _ns, _concept) \
114 typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::* _func##_type_var1##_type_var2##_type_var3##_type_var4##_concept)(); \
115 template <_func##_type_var1##_type_var2##_type_var3##_type_var4##_concept _Tp1> \
116 struct _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept { }; \
117 typedef _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept< \
118 &_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::__constraints> \
119 _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_type_var4##_concept
122 template <
class _Tp1,
class _Tp2>
123 struct _Aux_require_same { };
126 struct _Aux_require_same<_Tp,_Tp> {
typedef _Tp _Type; };
128 template <
class _Tp1,
class _Tp2>
129 struct _SameTypeConcept
131 void __constraints() {
132 typedef typename _Aux_require_same<_Tp1, _Tp2>::_Type _Required;
137 struct _IntegerConcept {
138 void __constraints() {
139 __error_type_must_be_an_integer_type();
142 template <>
struct _IntegerConcept<short> {
void __constraints() {} };
143 template <>
struct _IntegerConcept<unsigned short> {
void __constraints(){} };
144 template <>
struct _IntegerConcept<int> {
void __constraints() {} };
145 template <>
struct _IntegerConcept<unsigned int> {
void __constraints() {} };
146 template <>
struct _IntegerConcept<long> {
void __constraints() {} };
147 template <>
struct _IntegerConcept<unsigned long> {
void __constraints() {} };
148 template <>
struct _IntegerConcept<long long> {
void __constraints() {} };
149 template <>
struct _IntegerConcept<unsigned long long>
150 {
void __constraints() {} };
153 struct _SignedIntegerConcept {
154 void __constraints() {
155 __error_type_must_be_a_signed_integer_type();
158 template <>
struct _SignedIntegerConcept<short> {
void __constraints() {} };
159 template <>
struct _SignedIntegerConcept<int> {
void __constraints() {} };
160 template <>
struct _SignedIntegerConcept<long> {
void __constraints() {} };
161 template <>
struct _SignedIntegerConcept<long long> {
void __constraints(){}};
164 struct _UnsignedIntegerConcept {
165 void __constraints() {
166 __error_type_must_be_an_unsigned_integer_type();
169 template <>
struct _UnsignedIntegerConcept<unsigned short>
170 {
void __constraints() {} };
171 template <>
struct _UnsignedIntegerConcept<unsigned int>
172 {
void __constraints() {} };
173 template <>
struct _UnsignedIntegerConcept<unsigned long>
174 {
void __constraints() {} };
175 template <>
struct _UnsignedIntegerConcept<unsigned long long>
176 {
void __constraints() {} };
182 struct _DefaultConstructibleConcept
184 void __constraints() {
190 struct _AssignableConcept
192 void __constraints() {
194 __const_constraints(__a);
196 void __const_constraints(
const _Tp& __b) {
205 struct _CopyConstructibleConcept
207 void __constraints() {
209 _Tp* __ptr _IsUnused = &__a;
210 __const_constraints(__a);
212 void __const_constraints(
const _Tp& __a) {
213 _Tp __c _IsUnused(__a);
214 const _Tp* __ptr _IsUnused = &__a;
221 struct _SGIAssignableConcept
223 void __constraints() {
224 _Tp __b _IsUnused(__a);
226 __const_constraints(__a);
228 void __const_constraints(
const _Tp& __b) {
229 _Tp __c _IsUnused(__b);
235 template <
class _From,
class _To>
236 struct _ConvertibleConcept
238 void __constraints() {
239 _To __y _IsUnused = __x;
254 void __aux_require_boolean_expr(
const _Tp& __t) {
255 bool __x _IsUnused = __t;
260 struct _EqualityComparableConcept
262 void __constraints() {
263 __aux_require_boolean_expr(__a == __b);
269 struct _LessThanComparableConcept
271 void __constraints() {
272 __aux_require_boolean_expr(__a < __b);
279 struct _ComparableConcept
281 void __constraints() {
282 __aux_require_boolean_expr(__a < __b);
283 __aux_require_boolean_expr(__a > __b);
284 __aux_require_boolean_expr(__a <= __b);
285 __aux_require_boolean_expr(__a >= __b);
290 #define _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(_OP,_NAME) \
291 template <class _First, class _Second> \
293 void __constraints() { (void)__constraints_(); } \
294 bool __constraints_() { \
295 return __a _OP __b; \
301 #define _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(_OP,_NAME) \
302 template <class _Ret, class _First, class _Second> \
304 void __constraints() { (void)__constraints_(); } \
305 _Ret __constraints_() { \
306 return __a _OP __b; \
312 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(==, _EqualOpConcept);
313 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(!=, _NotEqualOpConcept);
314 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<, _LessThanOpConcept);
315 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<=, _LessEqualOpConcept);
316 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>, _GreaterThanOpConcept);
317 _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>=, _GreaterEqualOpConcept);
319 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(+, _PlusOpConcept);
320 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(*, _TimesOpConcept);
321 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(/, _DivideOpConcept);
322 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(-, _SubtractOpConcept);
323 _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(%, _ModOpConcept);
325 #undef _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT
326 #undef _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT
331 template <
class _Func,
class _Return>
332 struct _GeneratorConcept
334 void __constraints() {
335 const _Return& __r _IsUnused = __f();
341 template <
class _Func>
342 struct _GeneratorConcept<_Func,void>
344 void __constraints() {
350 template <
class _Func,
class _Return,
class _Arg>
351 struct _UnaryFunctionConcept
353 void __constraints() {
361 template <
class _Func,
class _Arg>
362 struct _UnaryFunctionConcept<_Func, void, _Arg> {
363 void __constraints() {
370 template <
class _Func,
class _Return,
class _First,
class _Second>
371 struct _BinaryFunctionConcept
373 void __constraints() {
374 __r = __f(__first, __second);
382 template <
class _Func,
class _First,
class _Second>
383 struct _BinaryFunctionConcept<_Func, void, _First, _Second>
385 void __constraints() {
386 __f(__first, __second);
393 template <
class _Func,
class _Arg>
394 struct _UnaryPredicateConcept
396 void __constraints() {
397 __aux_require_boolean_expr(__f(__arg));
403 template <
class _Func,
class _First,
class _Second>
404 struct _BinaryPredicateConcept
406 void __constraints() {
407 __aux_require_boolean_expr(__f(__a, __b));
415 template <
class _Func,
class _First,
class _Second>
416 struct _Const_BinaryPredicateConcept {
417 void __constraints() {
418 __const_constraints(__f);
420 void __const_constraints(
const _Func& __fun) {
421 __function_requires<_BinaryPredicateConcept<_Func, _First, _Second> >();
423 __aux_require_boolean_expr(__fun(__a, __b));
434 struct _TrivialIteratorConcept
436 void __constraints() {
438 __function_requires< _AssignableConcept<_Tp> >();
439 __function_requires< _EqualityComparableConcept<_Tp> >();
447 struct _Mutable_TrivialIteratorConcept
449 void __constraints() {
450 __function_requires< _TrivialIteratorConcept<_Tp> >();
457 struct _InputIteratorConcept
459 void __constraints() {
460 __function_requires< _TrivialIteratorConcept<_Tp> >();
467 __function_requires< _ConvertibleConcept<
476 template <
class _Tp,
class _ValueT>
477 struct _OutputIteratorConcept
479 void __constraints() {
480 __function_requires< _AssignableConcept<_Tp> >();
486 _ValueT __val()
const;
489 template<
typename _Tp>
490 struct _Is_vector_bool_iterator
491 {
static const bool __value =
false; };
493 #ifdef _GLIBCXX_DEBUG
494 namespace __cont = ::std::_GLIBCXX_STD_C;
501 struct _Is_vector_bool_iterator<
__cont::_Bit_iterator>
502 {
static const bool __value =
true; };
506 struct _Is_vector_bool_iterator<
__cont::_Bit_const_iterator>
507 {
static const bool __value =
true; };
510 template <
typename _It,
typename _Seq,
typename _Tag>
511 struct _Is_vector_bool_iterator<
__gnu_debug::_Safe_iterator<_It, _Seq, _Tag> >
512 : _Is_vector_bool_iterator<_It> { };
514 template <class _Tp, bool = _Is_vector_bool_iterator<_Tp>::__value>
515 struct _ForwardIteratorReferenceConcept
517 void __constraints() {
518 #if __cplusplus >= 201103L
521 "reference type of a forward iterator must be a real reference");
526 template <class _Tp, bool = _Is_vector_bool_iterator<_Tp>::__value>
527 struct _Mutable_ForwardIteratorReferenceConcept
529 void __constraints() {
532 __function_requires< _SameTypeConcept<_Ref, _Val&> >();
538 struct _ForwardIteratorReferenceConcept<_Tp, true>
540 void __constraints() { }
545 struct _Mutable_ForwardIteratorReferenceConcept<_Tp, true>
547 void __constraints() { }
550 #pragma GCC diagnostic push
551 #pragma GCC diagnostic ignored "-Wunused-variable"
554 struct _ForwardIteratorConcept
556 void __constraints() {
557 __function_requires< _InputIteratorConcept<_Tp> >();
558 __function_requires< _DefaultConstructibleConcept<_Tp> >();
559 __function_requires< _ConvertibleConcept<
562 __function_requires< _ForwardIteratorReferenceConcept<_Tp> >();
564 const _Tp& __k = __i++;
573 struct _Mutable_ForwardIteratorConcept
575 void __constraints() {
576 __function_requires< _ForwardIteratorConcept<_Tp> >();
579 __function_requires< _Mutable_ForwardIteratorReferenceConcept<_Tp> >();
585 struct _BidirectionalIteratorConcept
587 void __constraints() {
588 __function_requires< _ForwardIteratorConcept<_Tp> >();
589 __function_requires< _ConvertibleConcept<
593 const _Tp& __k = __i--;
601 struct _Mutable_BidirectionalIteratorConcept
603 void __constraints() {
604 __function_requires< _BidirectionalIteratorConcept<_Tp> >();
605 __function_requires< _Mutable_ForwardIteratorConcept<_Tp> >();
612 struct _RandomAccessIteratorConcept
614 void __constraints() {
615 __function_requires< _BidirectionalIteratorConcept<_Tp> >();
616 __function_requires< _ComparableConcept<_Tp> >();
617 __function_requires< _ConvertibleConcept<
622 _Tp& __j = __i += __n;
623 __i = __i + __n; __i = __n + __i;
624 _Tp& __k = __i -= __n;
636 struct _Mutable_RandomAccessIteratorConcept
638 void __constraints() {
639 __function_requires< _RandomAccessIteratorConcept<_Tp> >();
640 __function_requires< _Mutable_BidirectionalIteratorConcept<_Tp> >();
646 #pragma GCC diagnostic pop
651 template <
class _Container>
652 struct _ContainerConcept
654 typedef typename _Container::value_type _Value_type;
655 typedef typename _Container::difference_type _Difference_type;
656 typedef typename _Container::size_type _Size_type;
657 typedef typename _Container::const_reference _Const_reference;
658 typedef typename _Container::const_pointer _Const_pointer;
659 typedef typename _Container::const_iterator _Const_iterator;
661 void __constraints() {
662 __function_requires< _InputIteratorConcept<_Const_iterator> >();
663 __function_requires< _AssignableConcept<_Container> >();
664 const _Container __c;
668 __n = __c.max_size();
676 template <
class _Container>
677 struct _Mutable_ContainerConcept
679 typedef typename _Container::value_type _Value_type;
680 typedef typename _Container::reference _Reference;
681 typedef typename _Container::iterator _Iterator;
682 typedef typename _Container::pointer _Pointer;
684 void __constraints() {
685 __function_requires< _ContainerConcept<_Container> >();
686 __function_requires< _AssignableConcept<_Value_type> >();
687 __function_requires< _InputIteratorConcept<_Iterator> >();
694 _Container __c, __c2;
697 template <
class _ForwardContainer>
698 struct _ForwardContainerConcept
700 void __constraints() {
701 __function_requires< _ContainerConcept<_ForwardContainer> >();
702 typedef typename _ForwardContainer::const_iterator _Const_iterator;
703 __function_requires< _ForwardIteratorConcept<_Const_iterator> >();
707 template <
class _ForwardContainer>
708 struct _Mutable_ForwardContainerConcept
710 void __constraints() {
711 __function_requires< _ForwardContainerConcept<_ForwardContainer> >();
712 __function_requires< _Mutable_ContainerConcept<_ForwardContainer> >();
713 typedef typename _ForwardContainer::iterator _Iterator;
714 __function_requires< _Mutable_ForwardIteratorConcept<_Iterator> >();
718 template <
class _ReversibleContainer>
719 struct _ReversibleContainerConcept
721 typedef typename _ReversibleContainer::const_iterator _Const_iterator;
722 typedef typename _ReversibleContainer::const_reverse_iterator
723 _Const_reverse_iterator;
725 void __constraints() {
726 __function_requires< _ForwardContainerConcept<_ReversibleContainer> >();
727 __function_requires< _BidirectionalIteratorConcept<_Const_iterator> >();
729 _BidirectionalIteratorConcept<_Const_reverse_iterator> >();
731 const _ReversibleContainer __c;
732 _Const_reverse_iterator __i = __c.rbegin();
737 template <
class _ReversibleContainer>
738 struct _Mutable_ReversibleContainerConcept
740 typedef typename _ReversibleContainer::iterator _Iterator;
741 typedef typename _ReversibleContainer::reverse_iterator _Reverse_iterator;
743 void __constraints() {
744 __function_requires<_ReversibleContainerConcept<_ReversibleContainer> >();
746 _Mutable_ForwardContainerConcept<_ReversibleContainer> >();
747 __function_requires<_Mutable_BidirectionalIteratorConcept<_Iterator> >();
749 _Mutable_BidirectionalIteratorConcept<_Reverse_iterator> >();
751 _Reverse_iterator __i = __c.rbegin();
754 _ReversibleContainer __c;
757 template <
class _RandomAccessContainer>
758 struct _RandomAccessContainerConcept
760 typedef typename _RandomAccessContainer::size_type _Size_type;
761 typedef typename _RandomAccessContainer::const_reference _Const_reference;
762 typedef typename _RandomAccessContainer::const_iterator _Const_iterator;
763 typedef typename _RandomAccessContainer::const_reverse_iterator
764 _Const_reverse_iterator;
766 void __constraints() {
768 _ReversibleContainerConcept<_RandomAccessContainer> >();
769 __function_requires< _RandomAccessIteratorConcept<_Const_iterator> >();
771 _RandomAccessIteratorConcept<_Const_reverse_iterator> >();
773 const _RandomAccessContainer __c;
774 _Const_reference __r _IsUnused = __c[__n];
779 template <
class _RandomAccessContainer>
780 struct _Mutable_RandomAccessContainerConcept
782 typedef typename _RandomAccessContainer::size_type _Size_type;
783 typedef typename _RandomAccessContainer::reference _Reference;
784 typedef typename _RandomAccessContainer::iterator _Iterator;
785 typedef typename _RandomAccessContainer::reverse_iterator _Reverse_iterator;
787 void __constraints() {
789 _RandomAccessContainerConcept<_RandomAccessContainer> >();
791 _Mutable_ReversibleContainerConcept<_RandomAccessContainer> >();
792 __function_requires< _Mutable_RandomAccessIteratorConcept<_Iterator> >();
794 _Mutable_RandomAccessIteratorConcept<_Reverse_iterator> >();
796 _Reference __r _IsUnused = __c[__i];
799 _RandomAccessContainer __c;
803 template <
class _Sequence>
804 struct _SequenceConcept
806 typedef typename _Sequence::reference _Reference;
807 typedef typename _Sequence::const_reference _Const_reference;
809 void __constraints() {
813 __function_requires< _Mutable_ForwardContainerConcept<_Sequence> >();
814 __function_requires< _DefaultConstructibleConcept<_Sequence> >();
817 __c _IsUnused(__n, __t),
818 __c2 _IsUnused(__first, __last);
820 __c.insert(__p, __t);
821 __c.insert(__p, __n, __t);
822 __c.insert(__p, __first, __last);
827 _Reference __r _IsUnused = __c.front();
829 __const_constraints(__c);
831 void __const_constraints(
const _Sequence& __c) {
832 _Const_reference __r _IsUnused = __c.front();
834 typename _Sequence::value_type __t;
835 typename _Sequence::size_type __n;
836 typename _Sequence::value_type *__first, *__last;
837 typename _Sequence::iterator __p, __q;
840 template <
class _FrontInsertionSequence>
841 struct _FrontInsertionSequenceConcept
843 void __constraints() {
844 __function_requires< _SequenceConcept<_FrontInsertionSequence> >();
849 _FrontInsertionSequence __c;
850 typename _FrontInsertionSequence::value_type __t;
853 template <
class _BackInsertionSequence>
854 struct _BackInsertionSequenceConcept
856 typedef typename _BackInsertionSequence::reference _Reference;
857 typedef typename _BackInsertionSequence::const_reference _Const_reference;
859 void __constraints() {
860 __function_requires< _SequenceConcept<_BackInsertionSequence> >();
864 _Reference __r _IsUnused = __c.back();
866 void __const_constraints(
const _BackInsertionSequence& __c) {
867 _Const_reference __r _IsUnused = __c.back();
869 _BackInsertionSequence __c;
870 typename _BackInsertionSequence::value_type __t;
873 _GLIBCXX_END_NAMESPACE_VERSION
876 #pragma GCC diagnostic pop
ISO C++ entities toplevel namespace is std.
GNU extensions for public use.
GNU debug classes for public use.
Traits class for iterators.
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.