Skip to content
Related Articles

Related Articles

Improve Article

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:



template<class T>
struct remove_cv;


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++:


// 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;
A: false
B: false
C: true
D: false


Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for foundation plus STL.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :