add_cv Class


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at add_cv Class.

Makes const/volatile type from type.

template <class Ty>  
struct add_cv;  
template <class T>using add_cv_t = typename add_cv<T>::type;  


The type to modify.

An instance of the type modifier holds the modified-type add_volatile Class< add_const Class<Ty> >.

#include <type_traits>   
#include <iostream>   
int main()   
    std::add_cv_t<int> *p = (const volatile int *)0;   
    p = p;  // to quiet "unused" warning   
    std::cout << "add_cv<int> == "   
        << typeid(*p).name() << std::endl;   
    return (0);   

add_cv_t<int> == int  

Header: <type_traits>

Namespace: std

remove_const Class
remove_volatile Class