std:: remove_cvref
From cppreference.net
C++
Metaprogramming library
| Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
(C++14)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
헤더에 정의됨
<type_traits>
|
||
|
template
<
class
T
>
struct remove_cvref ; |
(C++20부터) | |
타입
T
가 참조 타입인 경우, 최상위 cv-한정자가 제거된
T
가 참조하는 타입을 멤버 typedef
type
으로 제공합니다. 그렇지 않은 경우
type
은 최상위 cv-한정자가 제거된
T
입니다.
프로그램이
std::remove_cvref
에 대한 특수화를 추가하는 경우, 동작은 정의되지 않습니다.
목차 |
멤버 타입
| 이름 | 정의 |
type
|
T
가 참조하는 타입 또는
T
가 참조가 아닌 경우
T
자체에서 최상위 cv-한정자가 제거된 타입
|
헬퍼 타입
|
template
<
class
T
>
using remove_cvref_t = remove_cvref < T > :: type ; |
(C++20부터) | |
가능한 구현
template<class T> struct remove_cvref { using type = std::remove_cv_t<std::remove_reference_t<T>>; }; |
참고 사항
| 기능 테스트 매크로 | 값 | 표준 | 기능 |
|---|---|---|---|
__cpp_lib_remove_cvref
|
201711L
|
(C++20) |
std::remove_cvref
|
예제
이 코드 실행
#include <type_traits> int main() { static_assert(std::is_same_v<std::remove_cvref_t<int>, int>); static_assert(std::is_same_v<std::remove_cvref_t<int&>, int>); static_assert(std::is_same_v<std::remove_cvref_t<int&&>, int>); static_assert(std::is_same_v<std::remove_cvref_t<const int&>, int>); static_assert(std::is_same_v<std::remove_cvref_t<const int[2]>, int[2]>); static_assert(std::is_same_v<std::remove_cvref_t<const int(&)[2]>, int[2]>); static_assert(std::is_same_v<std::remove_cvref_t<int(int)>, int(int)>); }
참고 항목
|
(C++11)
(C++11)
(C++11)
|
주어진 타입에서
const
및/또는
volatile
지정자를 제거함
(클래스 템플릿) |
|
(C++11)
|
주어진 타입에서 참조를 제거함
(클래스 템플릿) |
|
(C++11)
|
함수 인자를 값으로 전달할 때와 같은 타입 변환을 적용함
(클래스 템플릿) |