次の方法で共有


add_cv Class

 

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

Makes const/volatile type from type.

Syntax

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

Parameters

Ty
The type to modify.

Remarks

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

Example

#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  

Requirements

Header: <type_traits>

Namespace: std

See Also

<type_traits>
remove_const Class
remove_volatile Class