namespace std {
template <class T>
struct remove_cv {
using type = …;
};
template <class T>
using remove_cv_t = typename remove_cv<T>::type; // C++14
}
概要
型のconst-volatile修飾を除去する。
効果
remove_cvは、型Tに含まれる最上位のconst-volatile修飾を除去した型を、メンバ型typeとして定義する。
例
#include <type_traits>
static_assert(std::is_same<
std::remove_cv<const int>::type,
int
>::value,
"transform from const int to int");
static_assert(std::is_same<
std::remove_cv<const volatile int>::type,
int
>::value,
"transform from const volatile int to int");
static_assert(std::is_same<
std::remove_cv<const int*>::type,
const int*
>::value,
"transform from const int* to const int*");
static_assert(std::is_same<
std::remove_cv<const int&>::type,
const int&
>::value,
"transform from const int& to const int&");
static_assert(std::is_same<
std::remove_cv<int* const>::type,
int*
>::value,
"transform from int* const to int*");
int main() {}
出力
バージョン
言語
- C++11
処理系
- Clang: 3.0 ✅
- GCC: 4.3.6 ✅
- Visual C++: 2008 (std::tr1) ✅, 2010 ✅, 2012 ✅, 2013 ✅, 2015 ✅
remove_cv_tは2013から