头文件:
#include
模板类别:
template
struct remove_volatile;
句法:
std::remove_volatile::value
参数:模板std :: rmeove_volatile接受单个参数T(Trait类),以检查T是否不具有volatile限定。
返回值:模板std :: remove_volatile返回一个布尔值:
- 正确:如果T型没有挥发性限定。
- False:如果T类型具有挥发性限定。
下面是演示C++中std :: remove_volatile的程序:
程序1:
// C++ program to illustrate
// std::remove_volatile
#include
#include
using namespace std;
// Driver Code
int main()
{
// Declare variable of type
// volatile (int, const int, const int*,
// int * const and const int&)
typedef remove_volatile::type A;
typedef remove_volatile::type B;
typedef remove_volatile::type C;
typedef remove_volatile::type D;
typedef remove_volatile::type E;
cout << boolalpha;
// Checking the non-volatileness
// of the above declared variable
cout << "checking Non-volatileness:"
<< endl;
cout << "A: "
<< is_volatile::value
<< endl;
cout << "B: "
<< is_volatile::value
<< endl;
cout << "C: "
<< is_volatile::value
<< endl;
cout << "D: "
<< is_volatile::value
<< endl;
cout << "E: "
<< is_volatile::value
<< endl;
return 0;
}
输出:
checking Non-volatileness:
A: false
B: false
C: false
D: false
E: false
程式2:
// C++ program to illustrate
// std::remove_volatile
#include
#include
using namespace std;
// Driver Code
int main()
{
// Declare variable of type
// volatile (int, const int, const int*,
// int * const and const int&)
typedef add_volatile::type A;
typedef add_volatile::type B;
typedef remove_cv::type a;
typedef remove_cv::type b;
typedef remove_cv::type c;
cout << boolalpha;
// Checking the non-volatileness
// of the above declared variable
cout << "checking Non-volatileness:"
<< endl;
cout << "A: "
<< is_volatile::value
<< endl;
cout << "B: "
<< is_volatile::value
<< endl;
cout << "C: "
<< is_volatile::value
<< endl;
cout << "D: "
<< is_volatile::value
<< endl;
cout << "E: "
<< is_volatile::value
<< endl;
return 0;
}
输出:
checking Non-volatileness:
A: true
B: true
C: false
D: false
E: false
参考: http://www.cplusplus.com/reference/type_traits/remove_volatile/
要从最佳影片策划和实践问题去学习,检查了C++基础课程为基础,以先进的C++和C++ STL课程基础加上STL。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程” 。