__STL_CLASS_REQUIRES(_Tp, _Assignable);//这句频繁出现
可是整个STL源代码中似乎没有有意义的定义
下面是 __STL_CLASS_REQUIRES的定义:
// Some compilers lack the features that are necessary for concept checks.
// On those compilers we define the concept check macros to do nothing.
#define __STL_REQUIRES(__type_var, __concept) do {} while(0)
#define __STL_CLASS_REQUIRES(__type_var, __concept) \
static int __##__type_var##_##__concept
这个__STL_CLASS_REQUIRES什么也没有干,仅仅是定义了一个int型常量
// Use this macro inside of template classes, where you would
// like to place requirements on the template arguments to the class
// Warning: do not pass pointers and such (e.g. T*) in as the __type_var,
// since the type_var is used to construct identifiers. Instead typedef
// the pointer type, then use the typedef name for the __type_var.
#define __STL_CLASS_REQUIRES(__type_var, __concept) \
typedef void (* __func##__type_var##__concept)( __type_var ); \
template <__func##__type_var##__concept _Tp1> \
struct __dummy_struct_##__type_var##__concept { }; \
static __dummy_struct_##__type_var##__concept< \
__concept##_concept_specification< \
__type_var>::__concept##_requirement_violation> \
__dummy_ptr_##__type_var##__concept
这个定义也没有什么意义。光是定义,实现在哪里?没有搜索到。
下面是__STL_CLASS_REQUIRES_出现的一个例子:
template <class _Tp, class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
class vector : protected _Vector_base<_Tp, _Alloc>
{
// requirements:
_STL_CLASS_REQUIRES(_Tp, _Assignable);//这句频繁出现
可是整个STL源代码中似乎没有有意义的定义