williamr@2: /* williamr@2: * Copyright (c) 1999 williamr@2: * Silicon Graphics Computer Systems, Inc. williamr@2: * williamr@2: * Permission to use, copy, modify, distribute and sell this software williamr@2: * and its documentation for any purpose is hereby granted without fee, williamr@2: * provided that the above copyright notice appear in all copies and williamr@2: * that both that copyright notice and this permission notice appear williamr@2: * in supporting documentation. Silicon Graphics makes no williamr@2: * representations about the suitability of this software for any williamr@2: * purpose. It is provided "as is" without express or implied warranty. williamr@2: */ williamr@2: williamr@2: #ifndef __CONCEPT_CHECKS_H williamr@2: #define __CONCEPT_CHECKS_H williamr@2: williamr@2: /* williamr@2: Use these macro like assertions, but they assert properties williamr@2: on types (usually template arguments). In technical terms they williamr@2: verify whether a type "models" a "concept". williamr@2: williamr@2: This set of requirements and the terminology used here is derived williamr@2: from the book "Generic Programming and the STL" by Matt Austern williamr@2: (Addison Wesley). For further information please consult that williamr@2: book. The requirements also are intended to match the ANSI/ISO C++ williamr@2: standard. williamr@2: williamr@2: This file covers the basic concepts and the iterator concepts. williamr@2: There are several other files that provide the requirements williamr@2: for the STL containers: williamr@2: container_concepts.h williamr@2: sequence_concepts.h williamr@2: assoc_container_concepts.h williamr@2: williamr@2: Jeremy Siek, 1999 williamr@2: williamr@2: TO DO: williamr@2: - some issues with regards to concept classification and mutability williamr@2: including AssociativeContianer -> ForwardContainer williamr@2: and SortedAssociativeContainer -> ReversibleContainer williamr@2: - HashedAssociativeContainer williamr@2: - Allocator williamr@2: - Function Object Concepts williamr@2: williamr@2: */ williamr@2: williamr@2: #ifndef _STLP_USE_CONCEPT_CHECKS williamr@2: williamr@2: // Some compilers lack the features that are necessary for concept checks. williamr@2: // On those compilers we define the concept check macros to do nothing. williamr@2: #define _STLP_REQUIRES(__type_var, __concept) do {} while(0) williamr@2: #define _STLP_CLASS_REQUIRES(__type_var, __concept) \ williamr@2: static int __##__type_var##_##__concept williamr@2: #define _STLP_CONVERTIBLE(__type_x, __type_y) do {} while(0) williamr@2: #define _STLP_REQUIRES_SAME_TYPE(__type_x, __type_y) do {} while(0) williamr@2: #define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \ williamr@2: static int __##__type_x##__type_y##_require_same_type williamr@2: #define _STLP_GENERATOR_CHECK(__func, __ret) do {} while(0) williamr@2: #define _STLP_CLASS_GENERATOR_CHECK(__func, __ret) \ williamr@2: static int __##__func##__ret##_generator_check williamr@2: #define _STLP_UNARY_FUNCTION_CHECK(__func, __ret, __arg) do {} while(0) williamr@2: #define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \ williamr@2: static int __##__func##__ret##__arg##_unary_function_check williamr@2: #define _STLP_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ williamr@2: do {} while(0) williamr@2: #define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ williamr@2: static int __##__func##__ret##__first##__second##_binary_function_check williamr@2: #define _STLP_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ williamr@2: do {} while(0) williamr@2: #define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ williamr@2: static int __##__opname##__ret##__first##__second##_require_binary_op williamr@2: williamr@2: #else /* _STLP_USE_CONCEPT_CHECKS */ williamr@2: williamr@2: // This macro tests whether the template argument "__type_var" williamr@2: // satisfies the requirements of "__concept". Here is a list of concepts williamr@2: // that we know how to check: williamr@2: // _Allocator williamr@2: // _Assignable williamr@2: // _DefaultConstructible williamr@2: // _EqualityComparable williamr@2: // _LessThanComparable williamr@2: // _TrivialIterator williamr@2: // _InputIterator williamr@2: // _OutputIterator williamr@2: // _ForwardIterator williamr@2: // _BidirectionalIterator williamr@2: // _RandomAccessIterator williamr@2: // _Mutable_TrivialIterator williamr@2: // _Mutable_ForwardIterator williamr@2: // _Mutable_BidirectionalIterator williamr@2: // _Mutable_RandomAccessIterator williamr@2: williamr@2: #define _STLP_REQUIRES(__type_var, __concept) \ williamr@2: do { \ williamr@2: void (*__x)( __type_var ) = __concept##_concept_specification< __type_var >\ williamr@2: ::##__concept##_requirement_violation; __x = __x; } while (0) williamr@2: williamr@2: // Use this to check whether type X is convertible to type Y williamr@2: #define _STLP_CONVERTIBLE(__type_x, __type_y) \ williamr@2: do { \ williamr@2: void (*__x)( __type_x , __type_y ) = _STL_CONVERT_ERROR< __type_x , \ williamr@2: __type_y >::__type_X_is_not_convertible_to_type_Y; \ williamr@2: __x = __x; } while (0) williamr@2: williamr@2: // Use this to test whether two template arguments are the same type williamr@2: #define _STLP_REQUIRES_SAME_TYPE(__type_x, __type_y) \ williamr@2: do { \ williamr@2: void (*__x)( __type_x , __type_y ) = _STL_SAME_TYPE_ERROR< __type_x, \ williamr@2: __type_y >::__type_X_not_same_as_type_Y; \ williamr@2: __x = __x; } while (0) williamr@2: williamr@2: williamr@2: // function object checks williamr@2: #define _STLP_GENERATOR_CHECK(__func, __ret) \ williamr@2: do { \ williamr@2: __ret (*__x)( __func&) = \ williamr@2: _STL_GENERATOR_ERROR< \ williamr@2: __func, __ret>::__generator_requirement_violation; \ williamr@2: __x = __x; } while (0) williamr@2: williamr@2: williamr@2: #define _STLP_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \ williamr@2: do { \ williamr@2: __ret (*__x)( __func&, const __arg& ) = \ williamr@2: _STL_UNARY_FUNCTION_ERROR< \ williamr@2: __func, __ret, __arg>::__unary_function_requirement_violation; \ williamr@2: __x = __x; } while (0) williamr@2: williamr@2: williamr@2: #define _STLP_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ williamr@2: do { \ williamr@2: __ret (*__x)( __func&, const __first&, const __second& ) = \ williamr@2: _STL_BINARY_FUNCTION_ERROR< \ williamr@2: __func, __ret, __first, __second>::__binary_function_requirement_violation; \ williamr@2: __x = __x; } while (0) williamr@2: williamr@2: williamr@2: #define _STLP_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ williamr@2: do { \ williamr@2: __ret (*__x)( __first&, __second& ) = _STL_BINARY##__opname##_ERROR< \ williamr@2: __ret, __first, __second>::__binary_operator_requirement_violation; \ williamr@2: __ret (*__y)( const __first&, const __second& ) = \ williamr@2: _STL_BINARY##__opname##_ERROR< __ret, __first, __second>:: \ williamr@2: __const_binary_operator_requirement_violation; \ williamr@2: __y = __y; __x = __x; } while (0) williamr@2: williamr@2: williamr@2: #ifdef _STLP_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE williamr@2: williamr@2: #define _STLP_CLASS_REQUIRES(__type_var, __concept) williamr@2: #define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) williamr@2: #define _STLP_CLASS_GENERATOR_CHECK(__func, __ret) williamr@2: #define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) williamr@2: #define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) williamr@2: #define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) williamr@2: williamr@2: #else williamr@2: williamr@2: // Use this macro inside of template classes, where you would williamr@2: // like to place requirements on the template arguments to the class williamr@2: // Warning: do not pass pointers and such (e.g. T*) in as the __type_var, williamr@2: // since the type_var is used to construct identifiers. Instead typedef williamr@2: // the pointer type, then use the typedef name for the __type_var. williamr@2: #define _STLP_CLASS_REQUIRES(__type_var, __concept) \ williamr@2: typedef void (* __func##__type_var##__concept)( __type_var ); \ williamr@2: template <__func##__type_var##__concept _Tp1> \ williamr@2: struct __dummy_struct_##__type_var##__concept { }; \ williamr@2: static __dummy_struct_##__type_var##__concept< \ williamr@2: __concept##_concept_specification< \ williamr@2: __type_var>::__concept##_requirement_violation> \ williamr@2: __dummy_ptr_##__type_var##__concept williamr@2: williamr@2: williamr@2: #define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \ williamr@2: typedef void (* __func_##__type_x##__type_y##same_type)( __type_x, \ williamr@2: __type_y ); \ williamr@2: template < __func_##__type_x##__type_y##same_type _Tp1> \ williamr@2: struct __dummy_struct_##__type_x##__type_y##_same_type { }; \ williamr@2: static __dummy_struct_##__type_x##__type_y##_same_type< \ williamr@2: _STL_SAME_TYPE_ERROR<__type_x, __type_y>::__type_X_not_same_as_type_Y> \ williamr@2: __dummy_ptr_##__type_x##__type_y##_same_type williamr@2: williamr@2: williamr@2: #define _STLP_CLASS_GENERATOR_CHECK(__func, __ret) \ williamr@2: typedef __ret (* __f_##__func##__ret##_generator)( __func& ); \ williamr@2: template <__f_##__func##__ret##_generator _Tp1> \ williamr@2: struct __dummy_struct_##__func##__ret##_generator { }; \ williamr@2: static __dummy_struct_##__func##__ret##_generator< \ williamr@2: _STL_GENERATOR_ERROR< \ williamr@2: __func, __ret>::__generator_requirement_violation> \ williamr@2: __dummy_ptr_##__func##__ret##_generator williamr@2: williamr@2: williamr@2: #define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \ williamr@2: typedef __ret (* __f_##__func##__ret##__arg##_unary_check)( __func&, \ williamr@2: const __arg& ); \ williamr@2: template <__f_##__func##__ret##__arg##_unary_check _Tp1> \ williamr@2: struct __dummy_struct_##__func##__ret##__arg##_unary_check { }; \ williamr@2: static __dummy_struct_##__func##__ret##__arg##_unary_check< \ williamr@2: _STL_UNARY_FUNCTION_ERROR< \ williamr@2: __func, __ret, __arg>::__unary_function_requirement_violation> \ williamr@2: __dummy_ptr_##__func##__ret##__arg##_unary_check williamr@2: williamr@2: williamr@2: #define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ williamr@2: typedef __ret (* __f_##__func##__ret##__first##__second##_binary_check)( __func&, const __first&,\ williamr@2: const __second& ); \ williamr@2: template <__f_##__func##__ret##__first##__second##_binary_check _Tp1> \ williamr@2: struct __dummy_struct_##__func##__ret##__first##__second##_binary_check { }; \ williamr@2: static __dummy_struct_##__func##__ret##__first##__second##_binary_check< \ williamr@2: _STL_BINARY_FUNCTION_ERROR<__func, __ret, __first, __second>:: \ williamr@2: __binary_function_requirement_violation> \ williamr@2: __dummy_ptr_##__func##__ret##__first##__second##_binary_check williamr@2: williamr@2: williamr@2: #define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ williamr@2: typedef __ret (* __f_##__func##__ret##__first##__second##_binary_op)(const __first&, \ williamr@2: const __second& ); \ williamr@2: template <__f_##__func##__ret##__first##__second##_binary_op _Tp1> \ williamr@2: struct __dummy_struct_##__func##__ret##__first##__second##_binary_op { }; \ williamr@2: static __dummy_struct_##__func##__ret##__first##__second##_binary_op< \ williamr@2: _STL_BINARY##__opname##_ERROR<__ret, __first, __second>:: \ williamr@2: __binary_operator_requirement_violation> \ williamr@2: __dummy_ptr_##__func##__ret##__first##__second##_binary_op williamr@2: williamr@2: #endif williamr@2: williamr@2: /* helper class for finding non-const version of a type. Need to have williamr@2: something to assign to etc. when testing constant iterators. */ williamr@2: williamr@2: template williamr@2: struct _Mutable_trait { williamr@2: typedef _Tp _Type; williamr@2: }; williamr@2: template williamr@2: struct _Mutable_trait { williamr@2: typedef _Tp _Type; williamr@2: }; williamr@2: williamr@2: williamr@2: /* helper function for avoiding compiler warnings about unused variables */ williamr@2: template williamr@2: void __sink_unused_warning(_Type) { } williamr@2: williamr@2: template williamr@2: struct _STL_CONVERT_ERROR { williamr@2: static void williamr@2: __type_X_is_not_convertible_to_type_Y(_TypeX __x, _TypeY) { williamr@2: _TypeY __y = __x; williamr@2: __sink_unused_warning(__y); williamr@2: } williamr@2: }; williamr@2: williamr@2: williamr@2: template struct __check_equal { }; williamr@2: williamr@2: template williamr@2: struct _STL_SAME_TYPE_ERROR { williamr@2: static void williamr@4: __type_X_not_same_as_type_Y(_TypeX , _TypeY ) { williamr@2: __check_equal<_TypeX> t1 = __check_equal<_TypeY>(); williamr@2: } williamr@2: }; williamr@2: williamr@2: williamr@2: // Some Functon Object Checks williamr@2: williamr@2: template williamr@2: struct _STL_GENERATOR_ERROR { williamr@2: static _Ret __generator_requirement_violation(_Func& __f) { williamr@2: return __f(); williamr@2: } williamr@2: }; williamr@2: williamr@2: template williamr@2: struct _STL_GENERATOR_ERROR<_Func, void> { williamr@2: static void __generator_requirement_violation(_Func& __f) { williamr@2: __f(); williamr@2: } williamr@2: }; williamr@2: williamr@2: williamr@2: template williamr@2: struct _STL_UNARY_FUNCTION_ERROR { williamr@2: static _Ret williamr@2: __unary_function_requirement_violation(_Func& __f, williamr@2: const _Arg& __arg) { williamr@2: return __f(__arg); williamr@2: } williamr@2: }; williamr@2: williamr@2: template williamr@2: struct _STL_UNARY_FUNCTION_ERROR<_Func, void, _Arg> { williamr@2: static void williamr@2: __unary_function_requirement_violation(_Func& __f, williamr@2: const _Arg& __arg) { williamr@2: __f(__arg); williamr@2: } williamr@2: }; williamr@2: williamr@2: template williamr@2: struct _STL_BINARY_FUNCTION_ERROR { williamr@2: static _Ret williamr@2: __binary_function_requirement_violation(_Func& __f, williamr@4: const _First& __first, williamr@2: const _Second& __second) { williamr@2: return __f(__first, __second); williamr@2: } williamr@2: }; williamr@2: williamr@2: template williamr@2: struct _STL_BINARY_FUNCTION_ERROR<_Func, void, _First, _Second> { williamr@2: static void williamr@2: __binary_function_requirement_violation(_Func& __f, williamr@4: const _First& __first, williamr@2: const _Second& __second) { williamr@2: __f(__first, __second); williamr@2: } williamr@2: }; williamr@2: williamr@2: williamr@2: #define _STLP_DEFINE_BINARY_OP_CHECK(_OP, _NAME) \ williamr@2: template \ williamr@2: struct _STL_BINARY##_NAME##_ERROR { \ williamr@2: static _Ret \ williamr@2: __const_binary_operator_requirement_violation(const _First& __first, \ williamr@2: const _Second& __second) { \ williamr@2: return __first _OP __second; \ williamr@2: } \ williamr@2: static _Ret \ williamr@2: __binary_operator_requirement_violation(_First& __first, \ williamr@2: _Second& __second) { \ williamr@2: return __first _OP __second; \ williamr@2: } \ williamr@2: } williamr@2: williamr@2: _STLP_DEFINE_BINARY_OP_CHECK(==, _OP_EQUAL); williamr@2: _STLP_DEFINE_BINARY_OP_CHECK(!=, _OP_NOT_EQUAL); williamr@2: _STLP_DEFINE_BINARY_OP_CHECK(<, _OP_LESS_THAN); williamr@2: _STLP_DEFINE_BINARY_OP_CHECK(<=, _OP_LESS_EQUAL); williamr@2: _STLP_DEFINE_BINARY_OP_CHECK(>, _OP_GREATER_THAN); williamr@2: _STLP_DEFINE_BINARY_OP_CHECK(>=, _OP_GREATER_EQUAL); williamr@2: _STLP_DEFINE_BINARY_OP_CHECK(+, _OP_PLUS); williamr@2: _STLP_DEFINE_BINARY_OP_CHECK(*, _OP_TIMES); williamr@2: _STLP_DEFINE_BINARY_OP_CHECK(/, _OP_DIVIDE); williamr@2: _STLP_DEFINE_BINARY_OP_CHECK(-, _OP_SUBTRACT); williamr@2: _STLP_DEFINE_BINARY_OP_CHECK(%, _OP_MOD); williamr@2: // ... williamr@2: williamr@2: // TODO, add unary operators (prefix and postfix) williamr@2: williamr@2: /* williamr@2: The presence of this class is just to trick EDG into displaying williamr@2: these error messages before any other errors. Without the williamr@2: classes, the errors in the functions get reported after williamr@2: other class errors deep inside the library. The name williamr@2: choice just makes for an eye catching error message :) williamr@2: */ williamr@2: struct _STL_ERROR { williamr@2: williamr@2: template williamr@2: static _Type williamr@2: __default_constructor_requirement_violation(_Type) { williamr@2: return _Type(); williamr@2: } williamr@2: template williamr@2: static _Type williamr@2: __assignment_operator_requirement_violation(_Type __a) { williamr@2: __a = __a; williamr@2: return __a; williamr@2: } williamr@2: template williamr@2: static _Type williamr@2: __copy_constructor_requirement_violation(_Type __a) { williamr@2: _Type __c(__a); williamr@2: return __c; williamr@2: } williamr@2: template williamr@2: static _Type williamr@4: __const_parameter_required_for_copy_constructor(_Type /* __a */, williamr@2: const _Type& __b) { williamr@2: _Type __c(__b); williamr@2: return __c; williamr@2: } williamr@2: template williamr@2: static _Type williamr@4: __const_parameter_required_for_assignment_operator(_Type __a, williamr@2: const _Type& __b) { williamr@2: __a = __b; williamr@2: return __a; williamr@2: } williamr@2: template williamr@2: static _Type williamr@2: __less_than_comparable_requirement_violation(_Type __a, _Type __b) { williamr@2: if (__a < __b || __a > __b || __a <= __b || __a >= __b) return __a; williamr@2: return __b; williamr@2: } williamr@2: template williamr@2: static _Type williamr@2: __equality_comparable_requirement_violation(_Type __a, _Type __b) { williamr@2: if (__a == __b || __a != __b) return __a; williamr@2: return __b; williamr@2: } williamr@2: template williamr@2: static void williamr@2: __dereference_operator_requirement_violation(_Iterator __i) { williamr@2: __sink_unused_warning(*__i); williamr@2: } williamr@2: template williamr@2: static void williamr@2: __dereference_operator_and_assignment_requirement_violation(_Iterator __i) { williamr@2: *__i = *__i; williamr@2: } williamr@2: template williamr@2: static void williamr@2: __preincrement_operator_requirement_violation(_Iterator __i) { williamr@2: ++__i; williamr@2: } williamr@2: template williamr@2: static void williamr@2: __postincrement_operator_requirement_violation(_Iterator __i) { williamr@2: __i++; williamr@2: } williamr@2: template williamr@2: static void williamr@2: __predecrement_operator_requirement_violation(_Iterator __i) { williamr@2: --__i; williamr@2: } williamr@2: template williamr@2: static void williamr@2: __postdecrement_operator_requirement_violation(_Iterator __i) { williamr@2: __i--; williamr@2: } williamr@2: template williamr@2: static void williamr@2: __postincrement_operator_and_assignment_requirement_violation(_Iterator __i, williamr@2: _Type __t) { williamr@2: *__i++ = __t; williamr@2: } williamr@2: template williamr@2: static _Iterator williamr@4: __iterator_addition_assignment_requirement_violation(_Iterator __i, williamr@2: _Distance __n) { williamr@2: __i += __n; williamr@2: return __i; williamr@2: } williamr@2: template williamr@2: static _Iterator williamr@2: __iterator_addition_requirement_violation(_Iterator __i, _Distance __n) { williamr@2: __i = __i + __n; williamr@2: __i = __n + __i; williamr@2: return __i; williamr@2: } williamr@2: template williamr@2: static _Iterator williamr@2: __iterator_subtraction_assignment_requirement_violation(_Iterator __i, williamr@2: _Distance __n) { williamr@2: __i -= __n; williamr@2: return __i; williamr@2: } williamr@2: template williamr@2: static _Iterator williamr@2: __iterator_subtraction_requirement_violation(_Iterator __i, _Distance __n) { williamr@2: __i = __i - __n; williamr@2: return __i; williamr@2: } williamr@2: template williamr@2: static _Distance williamr@2: __difference_operator_requirement_violation(_Iterator __i, _Iterator __j, williamr@2: _Distance __n) { williamr@2: __n = __i - __j; williamr@2: return __n; williamr@2: } williamr@2: template williamr@2: static _Type williamr@2: __element_access_operator_requirement_violation(_Exp __x, _Type*, williamr@2: _Distance __n) { williamr@2: return __x[__n]; williamr@2: } williamr@2: template williamr@2: static void williamr@2: __element_assignment_operator_requirement_violation(_Exp __x, williamr@2: _Type* __t, williamr@2: _Distance __n) { williamr@2: __x[__n] = *__t; williamr@2: } williamr@2: williamr@2: }; /* _STL_ERROR */ williamr@2: williamr@2: /* Associated Type Requirements */ williamr@2: williamr@2: _STLP_BEGIN_NAMESPACE williamr@2: template struct iterator_traits; williamr@2: _STLP_END_NAMESPACE williamr@2: williamr@4: template williamr@2: struct __value_type_type_definition_requirement_violation { williamr@2: typedef typename __STD::iterator_traits<_Iter>::value_type value_type; williamr@2: }; williamr@2: williamr@4: template williamr@2: struct __difference_type_type_definition_requirement_violation { williamr@2: typedef typename __STD::iterator_traits<_Iter>::difference_type williamr@2: difference_type; williamr@2: }; williamr@2: williamr@4: template williamr@2: struct __reference_type_definition_requirement_violation { williamr@2: typedef typename __STD::iterator_traits<_Iter>::reference reference; williamr@2: }; williamr@2: williamr@4: template williamr@2: struct __pointer_type_definition_requirement_violation { williamr@2: typedef typename __STD::iterator_traits<_Iter>::pointer pointer; williamr@2: }; williamr@2: williamr@4: template williamr@2: struct __iterator_category_type_definition_requirement_violation { williamr@4: typedef typename __STD::iterator_traits<_Iter>::iterator_category williamr@2: iterator_category; williamr@2: }; williamr@2: williamr@2: /* Assignable Requirements */ williamr@2: williamr@2: williamr@2: template williamr@2: struct _Assignable_concept_specification { williamr@2: static void _Assignable_requirement_violation(_Type __a) { williamr@2: _STL_ERROR::__assignment_operator_requirement_violation(__a); williamr@2: _STL_ERROR::__copy_constructor_requirement_violation(__a); williamr@2: _STL_ERROR::__const_parameter_required_for_copy_constructor(__a,__a); williamr@2: _STL_ERROR::__const_parameter_required_for_assignment_operator(__a,__a); williamr@2: } williamr@2: }; williamr@2: williamr@2: /* DefaultConstructible Requirements */ williamr@2: williamr@2: williamr@2: template williamr@2: struct _DefaultConstructible_concept_specification { williamr@2: static void _DefaultConstructible_requirement_violation(_Type __a) { williamr@2: _STL_ERROR::__default_constructor_requirement_violation(__a); williamr@2: } williamr@2: }; williamr@2: williamr@2: /* EqualityComparable Requirements */ williamr@2: williamr@2: template williamr@2: struct _EqualityComparable_concept_specification { williamr@2: static void _EqualityComparable_requirement_violation(_Type __a) { williamr@2: _STL_ERROR::__equality_comparable_requirement_violation(__a, __a); williamr@2: } williamr@2: }; williamr@2: williamr@2: /* LessThanComparable Requirements */ williamr@2: template williamr@2: struct _LessThanComparable_concept_specification { williamr@2: static void _LessThanComparable_requirement_violation(_Type __a) { williamr@2: _STL_ERROR::__less_than_comparable_requirement_violation(__a, __a); williamr@2: } williamr@2: }; williamr@2: williamr@2: /* TrivialIterator Requirements */ williamr@2: williamr@2: template williamr@2: struct _TrivialIterator_concept_specification { williamr@2: static void williamr@2: _TrivialIterator_requirement_violation(_TrivialIterator __i) { williamr@2: typedef typename williamr@2: __value_type_type_definition_requirement_violation<_TrivialIterator>:: williamr@2: value_type __T; williamr@2: // Refinement of Assignable williamr@2: _Assignable_concept_specification<_TrivialIterator>:: williamr@2: _Assignable_requirement_violation(__i); williamr@2: // Refinement of DefaultConstructible williamr@2: _DefaultConstructible_concept_specification<_TrivialIterator>:: williamr@2: _DefaultConstructible_requirement_violation(__i); williamr@2: // Refinement of EqualityComparable williamr@2: _EqualityComparable_concept_specification<_TrivialIterator>:: williamr@2: _EqualityComparable_requirement_violation(__i); williamr@2: // Valid Expressions williamr@2: _STL_ERROR::__dereference_operator_requirement_violation(__i); williamr@2: } williamr@2: }; williamr@2: williamr@2: template williamr@2: struct _Mutable_TrivialIterator_concept_specification { williamr@2: static void williamr@2: _Mutable_TrivialIterator_requirement_violation(_TrivialIterator __i) { williamr@2: _TrivialIterator_concept_specification<_TrivialIterator>:: williamr@2: _TrivialIterator_requirement_violation(__i); williamr@2: // Valid Expressions williamr@2: _STL_ERROR::__dereference_operator_and_assignment_requirement_violation(__i); williamr@2: } williamr@2: }; williamr@2: williamr@2: /* InputIterator Requirements */ williamr@2: williamr@2: template williamr@2: struct _InputIterator_concept_specification { williamr@2: static void williamr@2: _InputIterator_requirement_violation(_InputIterator __i) { williamr@2: // Refinement of TrivialIterator williamr@2: _TrivialIterator_concept_specification<_InputIterator>:: williamr@2: _TrivialIterator_requirement_violation(__i); williamr@2: // Associated Types williamr@2: __difference_type_type_definition_requirement_violation<_InputIterator>(); williamr@2: __reference_type_definition_requirement_violation<_InputIterator>(); williamr@2: __pointer_type_definition_requirement_violation<_InputIterator>(); williamr@2: __iterator_category_type_definition_requirement_violation<_InputIterator>(); williamr@2: // Valid Expressions williamr@2: _STL_ERROR::__preincrement_operator_requirement_violation(__i); williamr@2: _STL_ERROR::__postincrement_operator_requirement_violation(__i); williamr@2: } williamr@2: }; williamr@2: williamr@2: /* OutputIterator Requirements */ williamr@2: williamr@2: template williamr@2: struct _OutputIterator_concept_specification { williamr@2: static void williamr@2: _OutputIterator_requirement_violation(_OutputIterator __i) { williamr@2: // Refinement of Assignable williamr@2: _Assignable_concept_specification<_OutputIterator>:: williamr@2: _Assignable_requirement_violation(__i); williamr@2: // Associated Types williamr@2: __iterator_category_type_definition_requirement_violation<_OutputIterator>(); williamr@2: // Valid Expressions williamr@2: _STL_ERROR::__dereference_operator_requirement_violation(__i); williamr@2: _STL_ERROR::__preincrement_operator_requirement_violation(__i); williamr@2: _STL_ERROR::__postincrement_operator_requirement_violation(__i); williamr@2: _STL_ERROR:: williamr@2: __postincrement_operator_and_assignment_requirement_violation(__i, *__i); williamr@2: } williamr@2: }; williamr@2: williamr@2: /* ForwardIterator Requirements */ williamr@2: williamr@2: template williamr@2: struct _ForwardIterator_concept_specification { williamr@2: static void williamr@2: _ForwardIterator_requirement_violation(_ForwardIterator __i) { williamr@2: // Refinement of InputIterator williamr@2: _InputIterator_concept_specification<_ForwardIterator>:: williamr@2: _InputIterator_requirement_violation(__i); williamr@2: } williamr@2: }; williamr@2: williamr@2: template williamr@2: struct _Mutable_ForwardIterator_concept_specification { williamr@2: static void williamr@2: _Mutable_ForwardIterator_requirement_violation(_ForwardIterator __i) { williamr@2: _ForwardIterator_concept_specification<_ForwardIterator>:: williamr@2: _ForwardIterator_requirement_violation(__i); williamr@2: // Refinement of OutputIterator williamr@2: _OutputIterator_concept_specification<_ForwardIterator>:: williamr@2: _OutputIterator_requirement_violation(__i); williamr@2: } williamr@2: }; williamr@2: williamr@2: /* BidirectionalIterator Requirements */ williamr@2: williamr@2: template williamr@2: struct _BidirectionalIterator_concept_specification { williamr@2: static void williamr@2: _BidirectionalIterator_requirement_violation(_BidirectionalIterator __i) { williamr@2: // Refinement of ForwardIterator williamr@2: _ForwardIterator_concept_specification<_BidirectionalIterator>:: williamr@2: _ForwardIterator_requirement_violation(__i); williamr@2: // Valid Expressions williamr@2: _STL_ERROR::__predecrement_operator_requirement_violation(__i); williamr@2: _STL_ERROR::__postdecrement_operator_requirement_violation(__i); williamr@2: } williamr@2: }; williamr@2: williamr@2: template williamr@2: struct _Mutable_BidirectionalIterator_concept_specification { williamr@2: static void williamr@2: _Mutable_BidirectionalIterator_requirement_violation( williamr@2: _BidirectionalIterator __i) williamr@2: { williamr@2: _BidirectionalIterator_concept_specification<_BidirectionalIterator>:: williamr@2: _BidirectionalIterator_requirement_violation(__i); williamr@2: // Refinement of mutable_ForwardIterator williamr@2: _Mutable_ForwardIterator_concept_specification<_BidirectionalIterator>:: williamr@2: _Mutable_ForwardIterator_requirement_violation(__i); williamr@2: typedef typename williamr@2: __value_type_type_definition_requirement_violation< williamr@2: _BidirectionalIterator>::value_type __T; williamr@2: typename _Mutable_trait<__T>::_Type* __tmp_ptr = 0; williamr@2: // Valid Expressions williamr@2: _STL_ERROR:: williamr@2: __postincrement_operator_and_assignment_requirement_violation(__i, williamr@2: *__tmp_ptr); williamr@2: } williamr@2: }; williamr@2: williamr@2: /* RandomAccessIterator Requirements */ williamr@2: williamr@2: template williamr@2: struct _RandomAccessIterator_concept_specification { williamr@2: static void williamr@2: _RandomAccessIterator_requirement_violation(_RandAccIter __i) { williamr@2: // Refinement of BidirectionalIterator williamr@2: _BidirectionalIterator_concept_specification<_RandAccIter>:: williamr@2: _BidirectionalIterator_requirement_violation(__i); williamr@2: // Refinement of LessThanComparable williamr@2: _LessThanComparable_concept_specification<_RandAccIter>:: williamr@2: _LessThanComparable_requirement_violation(__i); williamr@4: typedef typename williamr@2: __value_type_type_definition_requirement_violation<_RandAccIter> williamr@2: ::value_type williamr@2: value_type; williamr@2: typedef typename williamr@2: __difference_type_type_definition_requirement_violation<_RandAccIter> williamr@4: ::difference_type williamr@2: _Dist; williamr@2: typedef typename _Mutable_trait<_Dist>::_Type _MutDist; williamr@2: williamr@2: // Valid Expressions williamr@2: _STL_ERROR::__iterator_addition_assignment_requirement_violation(__i, williamr@2: _MutDist()); williamr@2: _STL_ERROR::__iterator_addition_requirement_violation(__i, williamr@2: _MutDist()); williamr@2: _STL_ERROR:: williamr@2: __iterator_subtraction_assignment_requirement_violation(__i, williamr@2: _MutDist()); williamr@2: _STL_ERROR::__iterator_subtraction_requirement_violation(__i, williamr@2: _MutDist()); williamr@2: _STL_ERROR::__difference_operator_requirement_violation(__i, __i, williamr@2: _MutDist()); williamr@2: typename _Mutable_trait::_Type* __dummy_ptr = 0; williamr@2: _STL_ERROR::__element_access_operator_requirement_violation(__i, williamr@2: __dummy_ptr, williamr@2: _MutDist()); williamr@2: } williamr@2: }; williamr@2: williamr@2: template williamr@2: struct _Mutable_RandomAccessIterator_concept_specification { williamr@2: static void williamr@2: _Mutable_RandomAccessIterator_requirement_violation(_RandAccIter __i) williamr@2: { williamr@2: _RandomAccessIterator_concept_specification<_RandAccIter>:: williamr@2: _RandomAccessIterator_requirement_violation(__i); williamr@2: // Refinement of mutable_BidirectionalIterator williamr@2: _Mutable_BidirectionalIterator_concept_specification<_RandAccIter>:: williamr@2: _Mutable_BidirectionalIterator_requirement_violation(__i); williamr@2: typedef typename williamr@2: __value_type_type_definition_requirement_violation<_RandAccIter> williamr@2: ::value_type williamr@2: value_type; williamr@2: typedef typename williamr@2: __difference_type_type_definition_requirement_violation<_RandAccIter> williamr@2: ::difference_type williamr@2: _Dist; williamr@2: williamr@2: typename _Mutable_trait::_Type* __tmp_ptr = 0; williamr@2: // Valid Expressions williamr@2: _STL_ERROR::__element_assignment_operator_requirement_violation(__i, williamr@2: __tmp_ptr, _Dist()); williamr@2: } williamr@2: }; williamr@2: williamr@2: #define _STLP_TYPEDEF_REQUIREMENT(__REQUIREMENT) \ williamr@2: template \ williamr@2: struct __##__REQUIREMENT##__typedef_requirement_violation { \ williamr@2: typedef typename Type::__REQUIREMENT __REQUIREMENT; \ williamr@2: }; williamr@2: williamr@2: _STLP_TYPEDEF_REQUIREMENT(value_type); williamr@2: _STLP_TYPEDEF_REQUIREMENT(difference_type); williamr@2: _STLP_TYPEDEF_REQUIREMENT(size_type); williamr@2: _STLP_TYPEDEF_REQUIREMENT(reference); williamr@2: _STLP_TYPEDEF_REQUIREMENT(const_reference); williamr@2: _STLP_TYPEDEF_REQUIREMENT(pointer); williamr@2: _STLP_TYPEDEF_REQUIREMENT(const_pointer); williamr@2: williamr@2: williamr@2: template williamr@2: struct _Allocator_concept_specification { williamr@2: static void williamr@2: _Allocator_requirement_violation(_Alloc __a) { williamr@2: // Refinement of DefaultConstructible williamr@2: _DefaultConstructible_concept_specification<_Alloc>:: williamr@2: _DefaultConstructible_requirement_violation(__a); williamr@2: // Refinement of EqualityComparable williamr@2: _EqualityComparable_concept_specification<_Alloc>:: williamr@2: _EqualityComparable_requirement_violation(__a); williamr@2: // Associated Types williamr@2: __value_type__typedef_requirement_violation<_Alloc>(); williamr@2: __difference_type__typedef_requirement_violation<_Alloc>(); williamr@2: __size_type__typedef_requirement_violation<_Alloc>(); williamr@2: __reference__typedef_requirement_violation<_Alloc>(); williamr@2: __const_reference__typedef_requirement_violation<_Alloc>(); williamr@2: __pointer__typedef_requirement_violation<_Alloc>(); williamr@2: __const_pointer__typedef_requirement_violation<_Alloc>(); williamr@2: typedef typename _Alloc::value_type _Type; williamr@2: _STLP_REQUIRES_SAME_TYPE(typename _Alloc::rebind<_Type>::other, _Alloc); williamr@2: } williamr@2: }; williamr@2: williamr@2: #endif /* _STLP_USE_CONCEPT_CHECKS */ williamr@2: williamr@2: #endif /* __CONCEPT_CHECKS_H */ williamr@2: williamr@2: // Local Variables: williamr@2: // mode:C++ williamr@2: // End: