14#ifndef __CONCEPT_CHECKS_H
15#define __CONCEPT_CHECKS_H
47#ifndef _STLP_USE_CONCEPT_CHECKS
51#define _STLP_REQUIRES(__type_var, __concept) do {} while(0)
52#define _STLP_CLASS_REQUIRES(__type_var, __concept) \
53 static int __##__type_var##_##__concept
54#define _STLP_CONVERTIBLE(__type_x, __type_y) do {} while(0)
55#define _STLP_REQUIRES_SAME_TYPE(__type_x, __type_y) do {} while(0)
56#define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \
57 static int __##__type_x##__type_y##_require_same_type
58#define _STLP_GENERATOR_CHECK(__func, __ret) do {} while(0)
59#define _STLP_CLASS_GENERATOR_CHECK(__func, __ret) \
60 static int __##__func##__ret##_generator_check
61#define _STLP_UNARY_FUNCTION_CHECK(__func, __ret, __arg) do {} while(0)
62#define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \
63 static int __##__func##__ret##__arg##_unary_function_check
64#define _STLP_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
66#define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
67 static int __##__func##__ret##__first##__second##_binary_function_check
68#define _STLP_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
70#define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
71 static int __##__opname##__ret##__first##__second##_require_binary_op
94#define _STLP_REQUIRES(__type_var, __concept) \
96 void (*__x)( __type_var ) = __concept##_concept_specification< __type_var >\
97 ::##__concept##_requirement_violation; __x = __x; } while (0)
100#define _STLP_CONVERTIBLE(__type_x, __type_y) \
102 void (*__x)( __type_x , __type_y ) = _STL_CONVERT_ERROR< __type_x , \
103 __type_y >::__type_X_is_not_convertible_to_type_Y; \
104 __x = __x; } while (0)
107#define _STLP_REQUIRES_SAME_TYPE(__type_x, __type_y) \
109 void (*__x)( __type_x , __type_y ) = _STL_SAME_TYPE_ERROR< __type_x, \
110 __type_y >::__type_X_not_same_as_type_Y; \
111 __x = __x; } while (0)
115#define _STLP_GENERATOR_CHECK(__func, __ret) \
117 __ret (*__x)( __func&) = \
118 _STL_GENERATOR_ERROR< \
119 __func, __ret>::__generator_requirement_violation; \
120 __x = __x; } while (0)
123#define _STLP_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \
125 __ret (*__x)( __func&, const __arg& ) = \
126 _STL_UNARY_FUNCTION_ERROR< \
127 __func, __ret, __arg>::__unary_function_requirement_violation; \
128 __x = __x; } while (0)
131#define _STLP_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
133 __ret (*__x)( __func&, const __first&, const __second& ) = \
134 _STL_BINARY_FUNCTION_ERROR< \
135 __func, __ret, __first, __second>::__binary_function_requirement_violation; \
136 __x = __x; } while (0)
139#define _STLP_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
141 __ret (*__x)( __first&, __second& ) = _STL_BINARY##__opname##_ERROR< \
142 __ret, __first, __second>::__binary_operator_requirement_violation; \
143 __ret (*__y)( const __first&, const __second& ) = \
144 _STL_BINARY##__opname##_ERROR< __ret, __first, __second>:: \
145 __const_binary_operator_requirement_violation; \
146 __y = __y; __x = __x; } while (0)
149#ifdef _STLP_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE
151#define _STLP_CLASS_REQUIRES(__type_var, __concept)
152#define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y)
153#define _STLP_CLASS_GENERATOR_CHECK(__func, __ret)
154#define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg)
155#define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second)
156#define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second)
165#define _STLP_CLASS_REQUIRES(__type_var, __concept) \
166 typedef void (* __func##__type_var##__concept)( __type_var ); \
167 template <__func##__type_var##__concept _Tp1> \
168 struct __dummy_struct_##__type_var##__concept { }; \
169 static __dummy_struct_##__type_var##__concept< \
170 __concept##_concept_specification< \
171 __type_var>::__concept##_requirement_violation> \
172 __dummy_ptr_##__type_var##__concept
175#define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \
176 typedef void (* __func_##__type_x##__type_y##same_type)( __type_x, \
178 template < __func_##__type_x##__type_y##same_type _Tp1> \
179 struct __dummy_struct_##__type_x##__type_y##_same_type { }; \
180 static __dummy_struct_##__type_x##__type_y##_same_type< \
181 _STL_SAME_TYPE_ERROR<__type_x, __type_y>::__type_X_not_same_as_type_Y> \
182 __dummy_ptr_##__type_x##__type_y##_same_type
185#define _STLP_CLASS_GENERATOR_CHECK(__func, __ret) \
186 typedef __ret (* __f_##__func##__ret##_generator)( __func& ); \
187 template <__f_##__func##__ret##_generator _Tp1> \
188 struct __dummy_struct_##__func##__ret##_generator { }; \
189 static __dummy_struct_##__func##__ret##_generator< \
190 _STL_GENERATOR_ERROR< \
191 __func, __ret>::__generator_requirement_violation> \
192 __dummy_ptr_##__func##__ret##_generator
195#define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \
196 typedef __ret (* __f_##__func##__ret##__arg##_unary_check)( __func&, \
198 template <__f_##__func##__ret##__arg##_unary_check _Tp1> \
199 struct __dummy_struct_##__func##__ret##__arg##_unary_check { }; \
200 static __dummy_struct_##__func##__ret##__arg##_unary_check< \
201 _STL_UNARY_FUNCTION_ERROR< \
202 __func, __ret, __arg>::__unary_function_requirement_violation> \
203 __dummy_ptr_##__func##__ret##__arg##_unary_check
206#define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
207 typedef __ret (* __f_##__func##__ret##__first##__second##_binary_check)( __func&, const __first&,\
209 template <__f_##__func##__ret##__first##__second##_binary_check _Tp1> \
210 struct __dummy_struct_##__func##__ret##__first##__second##_binary_check { }; \
211 static __dummy_struct_##__func##__ret##__first##__second##_binary_check< \
212 _STL_BINARY_FUNCTION_ERROR<__func, __ret, __first, __second>:: \
213 __binary_function_requirement_violation> \
214 __dummy_ptr_##__func##__ret##__first##__second##_binary_check
217#define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
218 typedef __ret (* __f_##__func##__ret##__first##__second##_binary_op)(const __first&, \
220 template <__f_##__func##__ret##__first##__second##_binary_op _Tp1> \
221 struct __dummy_struct_##__func##__ret##__first##__second##_binary_op { }; \
222 static __dummy_struct_##__func##__ret##__first##__second##_binary_op< \
223 _STL_BINARY##__opname##_ERROR<__ret, __first, __second>:: \
224 __binary_operator_requirement_violation> \
225 __dummy_ptr_##__func##__ret##__first##__second##_binary_op
233struct _Mutable_trait {
237struct _Mutable_trait<
const _Tp> {
243template <
class _Type>
244void __sink_unused_warning(_Type) { }
246template <
class _TypeX,
class _TypeY>
247struct _STL_CONVERT_ERROR {
249 __type_X_is_not_convertible_to_type_Y(_TypeX __x, _TypeY) {
251 __sink_unused_warning(__y);
256template <
class _Type>
struct __check_equal { };
258template <
class _TypeX,
class _TypeY>
259struct _STL_SAME_TYPE_ERROR {
261 __type_X_not_same_as_type_Y(_TypeX , _TypeY ) {
262 __check_equal<_TypeX> t1 = __check_equal<_TypeY>();
269template <
class _Func,
class _Ret>
270struct _STL_GENERATOR_ERROR {
271 static _Ret __generator_requirement_violation(_Func& __f) {
276template <
class _Func>
277struct _STL_GENERATOR_ERROR<_Func,
void> {
278 static void __generator_requirement_violation(_Func& __f) {
284template <
class _Func,
class _Ret,
class _Arg>
285struct _STL_UNARY_FUNCTION_ERROR {
287 __unary_function_requirement_violation(_Func& __f,
293template <
class _Func,
class _Arg>
294struct _STL_UNARY_FUNCTION_ERROR<_Func,
void, _Arg> {
296 __unary_function_requirement_violation(_Func& __f,
302template <
class _Func,
class _Ret,
class _First,
class _Second>
303struct _STL_BINARY_FUNCTION_ERROR {
305 __binary_function_requirement_violation(_Func& __f,
306 const _First& __first,
307 const _Second& __second) {
308 return __f(__first, __second);
312template <
class _Func,
class _First,
class _Second>
313struct _STL_BINARY_FUNCTION_ERROR<_Func,
void, _First, _Second> {
315 __binary_function_requirement_violation(_Func& __f,
316 const _First& __first,
317 const _Second& __second) {
318 __f(__first, __second);
323#define _STLP_DEFINE_BINARY_OP_CHECK(_OP, _NAME) \
324template <class _Ret, class _First, class _Second> \
325struct _STL_BINARY##_NAME##_ERROR { \
327 __const_binary_operator_requirement_violation(const _First& __first, \
328 const _Second& __second) { \
329 return __first _OP __second; \
332 __binary_operator_requirement_violation(_First& __first, \
333 _Second& __second) { \
334 return __first _OP __second; \
338_STLP_DEFINE_BINARY_OP_CHECK(==, _OP_EQUAL);
339_STLP_DEFINE_BINARY_OP_CHECK(!=, _OP_NOT_EQUAL);
340_STLP_DEFINE_BINARY_OP_CHECK(<, _OP_LESS_THAN);
341_STLP_DEFINE_BINARY_OP_CHECK(<=, _OP_LESS_EQUAL);
342_STLP_DEFINE_BINARY_OP_CHECK(>, _OP_GREATER_THAN);
343_STLP_DEFINE_BINARY_OP_CHECK(>=, _OP_GREATER_EQUAL);
344_STLP_DEFINE_BINARY_OP_CHECK(+, _OP_PLUS);
345_STLP_DEFINE_BINARY_OP_CHECK(*, _OP_TIMES);
346_STLP_DEFINE_BINARY_OP_CHECK(/, _OP_DIVIDE);
347_STLP_DEFINE_BINARY_OP_CHECK(-, _OP_SUBTRACT);
348_STLP_DEFINE_BINARY_OP_CHECK(%, _OP_MOD);
362 template <
class _Type>
364 __default_constructor_requirement_violation(_Type) {
367 template <
class _Type>
369 __assignment_operator_requirement_violation(_Type __a) {
373 template <
class _Type>
375 __copy_constructor_requirement_violation(_Type __a) {
379 template <
class _Type>
381 __const_parameter_required_for_copy_constructor(_Type ,
386 template <
class _Type>
388 __const_parameter_required_for_assignment_operator(_Type __a,
393 template <
class _Type>
395 __less_than_comparable_requirement_violation(_Type __a, _Type __b) {
396 if (__a < __b || __a > __b || __a <= __b || __a >= __b)
return __a;
399 template <
class _Type>
401 __equality_comparable_requirement_violation(_Type __a, _Type __b) {
402 if (__a == __b || __a != __b)
return __a;
405 template <
class _Iterator>
407 __dereference_operator_requirement_violation(_Iterator __i) {
408 __sink_unused_warning(*__i);
410 template <
class _Iterator>
412 __dereference_operator_and_assignment_requirement_violation(_Iterator __i) {
415 template <
class _Iterator>
417 __preincrement_operator_requirement_violation(_Iterator __i) {
420 template <
class _Iterator>
422 __postincrement_operator_requirement_violation(_Iterator __i) {
425 template <
class _Iterator>
427 __predecrement_operator_requirement_violation(_Iterator __i) {
430 template <
class _Iterator>
432 __postdecrement_operator_requirement_violation(_Iterator __i) {
435 template <
class _Iterator,
class _Type>
437 __postincrement_operator_and_assignment_requirement_violation(_Iterator __i,
441 template <
class _Iterator,
class _Distance>
443 __iterator_addition_assignment_requirement_violation(_Iterator __i,
448 template <
class _Iterator,
class _Distance>
450 __iterator_addition_requirement_violation(_Iterator __i, _Distance
__n) {
455 template <
class _Iterator,
class _Distance>
457 __iterator_subtraction_assignment_requirement_violation(_Iterator __i,
462 template <
class _Iterator,
class _Distance>
464 __iterator_subtraction_requirement_violation(_Iterator __i, _Distance
__n) {
468 template <
class _Iterator,
class _Distance>
470 __difference_operator_requirement_violation(_Iterator __i, _Iterator __j,
475 template <
class _Exp,
class _Type,
class _Distance>
477 __element_access_operator_requirement_violation(
_Exp __x, _Type*,
481 template <
class _Exp,
class _Type,
class _Distance>
483 __element_assignment_operator_requirement_violation(
_Exp __x,
497template <
class _Iter>
498struct __value_type_type_definition_requirement_violation {
499 typedef typename __STD::iterator_traits<_Iter>::value_type value_type;
502template <
class _Iter>
503struct __difference_type_type_definition_requirement_violation {
504 typedef typename __STD::iterator_traits<_Iter>::difference_type
508template <
class _Iter>
509struct __reference_type_definition_requirement_violation {
510 typedef typename __STD::iterator_traits<_Iter>::reference
reference;
513template <
class _Iter>
514struct __pointer_type_definition_requirement_violation {
515 typedef typename __STD::iterator_traits<_Iter>::pointer
pointer;
518template <
class _Iter>
519struct __iterator_category_type_definition_requirement_violation {
520 typedef typename __STD::iterator_traits<_Iter>::iterator_category
527template <
class _Type>
528struct _Assignable_concept_specification {
529 static void _Assignable_requirement_violation(_Type __a) {
530 _STL_ERROR::__assignment_operator_requirement_violation(__a);
531 _STL_ERROR::__copy_constructor_requirement_violation(__a);
532 _STL_ERROR::__const_parameter_required_for_copy_constructor(__a,__a);
533 _STL_ERROR::__const_parameter_required_for_assignment_operator(__a,__a);
540template <
class _Type>
541struct _DefaultConstructible_concept_specification {
542 static void _DefaultConstructible_requirement_violation(_Type __a) {
543 _STL_ERROR::__default_constructor_requirement_violation(__a);
549template <
class _Type>
550struct _EqualityComparable_concept_specification {
551 static void _EqualityComparable_requirement_violation(_Type __a) {
552 _STL_ERROR::__equality_comparable_requirement_violation(__a, __a);
557template <
class _Type>
558struct _LessThanComparable_concept_specification {
559 static void _LessThanComparable_requirement_violation(_Type __a) {
560 _STL_ERROR::__less_than_comparable_requirement_violation(__a, __a);
566template <
class _TrivialIterator>
567struct _TrivialIterator_concept_specification {
569_TrivialIterator_requirement_violation(_TrivialIterator __i) {
571 __value_type_type_definition_requirement_violation<_TrivialIterator>::
574 _Assignable_concept_specification<_TrivialIterator>::
575 _Assignable_requirement_violation(__i);
577 _DefaultConstructible_concept_specification<_TrivialIterator>::
578 _DefaultConstructible_requirement_violation(__i);
580 _EqualityComparable_concept_specification<_TrivialIterator>::
581 _EqualityComparable_requirement_violation(__i);
583 _STL_ERROR::__dereference_operator_requirement_violation(__i);
587template <
class _TrivialIterator>
588struct _Mutable_TrivialIterator_concept_specification {
590_Mutable_TrivialIterator_requirement_violation(_TrivialIterator __i) {
591 _TrivialIterator_concept_specification<_TrivialIterator>::
592 _TrivialIterator_requirement_violation(__i);
594 _STL_ERROR::__dereference_operator_and_assignment_requirement_violation(__i);
600template <
class _InputIterator>
601struct _InputIterator_concept_specification {
603_InputIterator_requirement_violation(_InputIterator __i) {
605 _TrivialIterator_concept_specification<_InputIterator>::
606 _TrivialIterator_requirement_violation(__i);
608 __difference_type_type_definition_requirement_violation<_InputIterator>();
609 __reference_type_definition_requirement_violation<_InputIterator>();
610 __pointer_type_definition_requirement_violation<_InputIterator>();
611 __iterator_category_type_definition_requirement_violation<_InputIterator>();
613 _STL_ERROR::__preincrement_operator_requirement_violation(__i);
614 _STL_ERROR::__postincrement_operator_requirement_violation(__i);
620template <
class _OutputIterator>
621struct _OutputIterator_concept_specification {
623_OutputIterator_requirement_violation(_OutputIterator __i) {
625 _Assignable_concept_specification<_OutputIterator>::
626 _Assignable_requirement_violation(__i);
628 __iterator_category_type_definition_requirement_violation<_OutputIterator>();
630 _STL_ERROR::__dereference_operator_requirement_violation(__i);
631 _STL_ERROR::__preincrement_operator_requirement_violation(__i);
632 _STL_ERROR::__postincrement_operator_requirement_violation(__i);
634 __postincrement_operator_and_assignment_requirement_violation(__i, *__i);
640template <
class _ForwardIterator>
641struct _ForwardIterator_concept_specification {
643_ForwardIterator_requirement_violation(_ForwardIterator __i) {
645 _InputIterator_concept_specification<_ForwardIterator>::
646 _InputIterator_requirement_violation(__i);
650template <
class _ForwardIterator>
651struct _Mutable_ForwardIterator_concept_specification {
653_Mutable_ForwardIterator_requirement_violation(_ForwardIterator __i) {
654 _ForwardIterator_concept_specification<_ForwardIterator>::
655 _ForwardIterator_requirement_violation(__i);
657 _OutputIterator_concept_specification<_ForwardIterator>::
658 _OutputIterator_requirement_violation(__i);
664template <
class _B
idirectionalIterator>
665struct _BidirectionalIterator_concept_specification {
667_BidirectionalIterator_requirement_violation(_BidirectionalIterator __i) {
669 _ForwardIterator_concept_specification<_BidirectionalIterator>::
670 _ForwardIterator_requirement_violation(__i);
672 _STL_ERROR::__predecrement_operator_requirement_violation(__i);
673 _STL_ERROR::__postdecrement_operator_requirement_violation(__i);
677template <
class _B
idirectionalIterator>
678struct _Mutable_BidirectionalIterator_concept_specification {
680_Mutable_BidirectionalIterator_requirement_violation(
681 _BidirectionalIterator __i)
683 _BidirectionalIterator_concept_specification<_BidirectionalIterator>::
684 _BidirectionalIterator_requirement_violation(__i);
686 _Mutable_ForwardIterator_concept_specification<_BidirectionalIterator>::
687 _Mutable_ForwardIterator_requirement_violation(__i);
689 __value_type_type_definition_requirement_violation<
690 _BidirectionalIterator>::value_type
__T;
691 typename _Mutable_trait<__T>::_Type* __tmp_ptr = 0;
694 __postincrement_operator_and_assignment_requirement_violation(__i,
701template <
class _RandAccIter>
702struct _RandomAccessIterator_concept_specification {
704_RandomAccessIterator_requirement_violation(_RandAccIter __i) {
706 _BidirectionalIterator_concept_specification<_RandAccIter>::
707 _BidirectionalIterator_requirement_violation(__i);
709 _LessThanComparable_concept_specification<_RandAccIter>::
710 _LessThanComparable_requirement_violation(__i);
712 __value_type_type_definition_requirement_violation<_RandAccIter>
716 __difference_type_type_definition_requirement_violation<_RandAccIter>
719 typedef typename _Mutable_trait<_Dist>::_Type _MutDist;
722 _STL_ERROR::__iterator_addition_assignment_requirement_violation(__i,
724 _STL_ERROR::__iterator_addition_requirement_violation(__i,
727 __iterator_subtraction_assignment_requirement_violation(__i,
729 _STL_ERROR::__iterator_subtraction_requirement_violation(__i,
731 _STL_ERROR::__difference_operator_requirement_violation(__i, __i,
733 typename _Mutable_trait<value_type>::_Type* __dummy_ptr = 0;
734 _STL_ERROR::__element_access_operator_requirement_violation(__i,
740template <
class _RandAccIter>
741struct _Mutable_RandomAccessIterator_concept_specification {
743_Mutable_RandomAccessIterator_requirement_violation(_RandAccIter __i)
745 _RandomAccessIterator_concept_specification<_RandAccIter>::
746 _RandomAccessIterator_requirement_violation(__i);
748 _Mutable_BidirectionalIterator_concept_specification<_RandAccIter>::
749 _Mutable_BidirectionalIterator_requirement_violation(__i);
751 __value_type_type_definition_requirement_violation<_RandAccIter>
755 __difference_type_type_definition_requirement_violation<_RandAccIter>
759 typename _Mutable_trait<value_type>::_Type* __tmp_ptr = 0;
761 _STL_ERROR::__element_assignment_operator_requirement_violation(__i,
766#define _STLP_TYPEDEF_REQUIREMENT(__REQUIREMENT) \
767template <class Type> \
768struct __##__REQUIREMENT##__typedef_requirement_violation { \
769 typedef typename Type::__REQUIREMENT __REQUIREMENT; \
772_STLP_TYPEDEF_REQUIREMENT(value_type);
773_STLP_TYPEDEF_REQUIREMENT(difference_type);
774_STLP_TYPEDEF_REQUIREMENT(size_type);
776_STLP_TYPEDEF_REQUIREMENT(const_reference);
777_STLP_TYPEDEF_REQUIREMENT(
pointer);
778_STLP_TYPEDEF_REQUIREMENT(const_pointer);
781template <
class _Alloc>
782struct _Allocator_concept_specification {
784_Allocator_requirement_violation(
_Alloc __a) {
786 _DefaultConstructible_concept_specification<_Alloc>::
787 _DefaultConstructible_requirement_violation(__a);
789 _EqualityComparable_concept_specification<_Alloc>::
790 _EqualityComparable_requirement_violation(__a);
792 __value_type__typedef_requirement_violation<_Alloc>();
793 __difference_type__typedef_requirement_violation<_Alloc>();
794 __size_type__typedef_requirement_violation<_Alloc>();
795 __reference__typedef_requirement_violation<_Alloc>();
796 __const_reference__typedef_requirement_violation<_Alloc>();
797 __pointer__typedef_requirement_violation<_Alloc>();
798 __const_pointer__typedef_requirement_violation<_Alloc>();
799 typedef typename _Alloc::value_type _Type;
#define _STLP_REQUIRES_SAME_TYPE(__type_x, __type_y)
#define _STLP_BEGIN_NAMESPACE
#define _STLP_END_NAMESPACE
GLsizei const GLvoid * pointer
_CRTIMP short __cdecl _Exp(double *, double, short)