std::remove_cv in C++ with Example
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:
// C++ program to illustrate std::remove_cv #include <bits/stdc++.h> #include <type_traits> using namespace std; // Driver Code int main() { // Declare variable of type int, const // int, volatile int and const volatile int 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/
Please Login to comment...