std::remove_cv in C++ with Example
Last Updated :
12 Jun, 2020
The std::remove_cv template of C++ STL is present in the <type_traits> header file. The std::remove_cv template of C++ STL is used to get the type T without const and volatile qualification. It return the boolean value true if T is without const and volatile qualified, otherwise return false.
Header File:
#include<type_traits>
Template:
template<class T>
struct remove_cv;
Syntax:
std::remove_cv<T>::type a;
Parameter:The template std::remove_cv accepts a single parameter T(Trait class) to check whether T is without const and volatile qualified or not.
Return Value:
Below is the program to demonstrate std::remove_cv in C++:
Program:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;
int main()
{
typedef remove_cv< int >::type A;
typedef remove_cv< const int >::type B;
typedef remove_cv< volatile int >::type C;
typedef remove_cv< const volatile int &>::type D;
cout << boolalpha;
cout << "A: "
<< is_same< const volatile int , A>::value
<< endl;
cout << "B: "
<< is_same< const volatile int , B>::value
<< endl;
cout << "C: "
<< is_same< int , C>::value
<< endl;
cout << "D: "
<< is_same< int , D>::value
<< endl;
return 0;
}
|
Output:
A: false
B: false
C: true
D: false
Reference: http://www.cplusplus.com/reference/type_traits/remove_cv/
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...