偏特化模板

std::is_integral 实现原理

	// TEMPLATE CLASS _Is_integral
template<class _Ty>
	struct _Is_integral
		: false_type
	{	// determine whether _Ty is integral
	};


//有偏特化版本的类型继承的是true_type,即std::bool_constant<true>,其value是true,而无偏特化的,则是默认的继承false_type,value是false
//以下则表示 bool,char,unsigned char,都是integral类型
template<>
	struct _Is_integral<bool>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<char>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<unsigned char>
		: true_type
	{	// determine whether _Ty is integral
	};

猜你喜欢

转载自blog.csdn.net/shujianlove0/article/details/84564390