Namespaces
Variants

std:: remove_pointer

From cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
Type properties
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
헤더에 정의됨 <type_traits>
template < class T >
struct remove_pointer ;
(C++11부터)

T 가 가리키는 타입인 type 멤버 typedef를 제공합니다. T 가 포인터가 아닌 경우 type T 와 동일합니다.

프로그램이 std::remove_pointer 에 대한 특수화를 추가하는 경우, 그 동작은 정의되지 않습니다.

목차

멤버 타입

이름 정의
type T 가 가리키는 타입 또는 T 가 포인터가 아닌 경우 T 자체

헬퍼 타입

template < class T >
using remove_pointer_t = typename remove_pointer < T > :: type ;
(C++14 이후)

가능한 구현

template<class T> struct remove_pointer { typedef T type; };
template<class T> struct remove_pointer<T*> { typedef T type; };
template<class T> struct remove_pointer<T* const> { typedef T type; };
template<class T> struct remove_pointer<T* volatile> { typedef T type; };
template<class T> struct remove_pointer<T* const volatile> { typedef T type; };
**참고:** 제공된 HTML 코드 블록 내에는 번역이 필요한 일반 텍스트가 포함되어 있지 않습니다. 모든 내용이 C++ 코드(
 태그 내부)와 HTML 태그/속성으로 구성되어 있으며, 이들은 번역에서 제외되어야 합니다.

예제

#include <type_traits>
static_assert
(
    std::is_same_v<int, int> == true &&
    std::is_same_v<int, int*> == false &&
    std::is_same_v<int, int**> == false &&
    std::is_same_v<int, std::remove_pointer_t<int>> == true &&
    std::is_same_v<int, std::remove_pointer_t<int*>> == true &&
    std::is_same_v<int, std::remove_pointer_t<int**>> == false &&
    std::is_same_v<int, std::remove_pointer_t<int* const>> == true &&
    std::is_same_v<int, std::remove_pointer_t<int* volatile>> == true &&
    std::is_same_v<int, std::remove_pointer_t<int* const volatile>> == true
);
int main() {}

참고 항목

(C++11)
타입이 포인터 타입인지 확인
(클래스 템플릿)
주어진 타입에 포인터를 추가
(클래스 템플릿)