1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > integral_constant定义编译期常量

integral_constant定义编译期常量

时间:2018-09-20 21:24:27

相关推荐

integral_constant定义编译期常量

#include "stdafx.h"

#include <iostream>

#include <type_traits>

using namespace std;

/*

integral_constant就可方便地定义编译期常量,而无需再通过enum和static const变量方式,这也为定义编译期常量提供另一种方法。

integral_constant类 是所有traits类的基类,分别提供了以下功能:

value_type 表示值的类型

value表示值

type 表示自己, 因此可以用::type::value来获取值

true_type和false_type两个特化类用来表示bool值类型的traits,很多traits类都需要继承它们

template<class _Ty, _Ty _Val>

struct integral_constant

{

// convenient template for integral constant types

static _CONST_DATA

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。