名前空間
変種
操作

std::remove_pointer

From cppreference.com
< cpp‎ | types
 
 
メタプログラミングライブラリ
型特性
型のカテゴリ
(C++11)
(C++11)(DR*)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11) 
(C++11)
(C++11)
型のプロパティ
(C++11)
(C++11)
(C++14)
(C++11)(C++26で非推奨)
(C++11)(C++20まで*)
(C++11)(C++20で非推奨)
(C++11)
型特性定数
メタ関数
(C++17)
サポートされている操作
関係とプロパティクエリ
型の変更
(C++11)(C++11)(C++11)
remove_pointer
(C++11)

型の変換
(C++11)(C++23で非推奨)
(C++11)(C++23で非推奨)
(C++11)
(C++11)(C++20まで*)(C++17)

(C++11)
(C++17)
コンパイル時有理数演算
コンパイル時整数シーケンス
 
ヘッダ <type_traits> で定義
template< class T >
struct remove_pointer;
(C++11以降)

T が指す型、あるいは T がポインタでない場合は T と同じ型であるメンバエイリアス type を提供します。

プログラムが std::remove_pointer の特殊化を追加した場合、動作は未定義です。

目次

[編集] メンバ型

名前 定義
type 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; };

[編集]

#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() {}

[編集] 関連項目

型がポインタ型であるかをチェックする
(クラステンプレート) [編集]
与えられた型にポインタを追加する
(クラステンプレート) [編集]
English 日本語 中文(简体) 中文(繁體)