Related Articles

Related Articles

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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;
}

chevron_right


Output:

A: false
B: false
C: true
D: false

Reference: http://www.cplusplus.com/reference/type_traits/remove_cv/

Rated as one of the most sought after skills in the industry, own the basics of coding with our C++ STL Course and master the very concepts by intense problem-solving.




My Personal Notes arrow_drop_up
Recommended Articles
Page :