头文件:
#include
模板类别:
template< class T >
struct add_cv
句法:
std::add_const::type
参数:模板std :: add_cv接受单个参数T(Trait类),以检查T是否为const和volatile限定。
下面是在C++中演示std :: add_cv的程序:
程序:
// C++ program to illustrate
// std::add_cv
#include
#include
using namespace std;
// Driver Code
int main()
{
// Declare variables of int, const,
// volatile, const volatile using add_cv
typedef add_cv::type A;
typedef add_cv::type B;
typedef add_cv::type C;
typedef add_cv::type D;
cout << boolalpha;
// Check the type of variable declared
// above is volatile or not
cout << "A: "
<< is_volatile::value
<< endl;
cout << "B: "
<< is_volatile::value
<< endl;
cout << "C: "
<< is_volatile::value
<< endl;
cout
<< "D: "
<< is_volatile::value
<< endl;
return 0;
}
输出:
typedefs of const volatile int:
A: true
B: true
C: true
D: true
参考: http : //www.cplusplus.com/reference/type_traits/add_cv/
要从最佳影片策划和实践问题去学习,检查了C++基础课程为基础,以先进的C++和C++ STL课程基础加上STL。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程” 。