首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::remove_pointer

Defined in header <type_traits>

template< class T > struct remove_pointer;

(since C++11)

提供成员类型胡枝子f。type所指的类型。T,或者,如果T不是指针type是相同的T...

成员类型

Name

Definition

type

the type pointed to by T or T if it's not a pointer

帮助者类型

template< class T > using remove_pointer_t = typename remove_pointer<T>::type;

(since C++14)

可能的实施

模板<class T>结构删除[医]指针{tydufT类型;};模板<class T>结构删除[医]指针<T%2A>{tydufT类型;};模板<class T>结构删除[医]指针<T%2A模板<class T>结构删除[医]指针<T%2A挥发性>{ty胡枝子T型;};模板<class T>结构删除[医]指针<T%2AConst挥发物>{tydurif T型;};

*。

二次

代码语言:javascript
复制
#include <iostream>
#include <type_traits>
 
template<class T1, class T2>
void print_is_same() 
{
    std::cout << std::is_same<T1, T2>() << '\n';
}
 
void print_separator() 
{
    std::cout << "-----\n";
}
 
int main() 
{
    std::cout << std::boolalpha;
 
    print_is_same<int, int>();   // true
    print_is_same<int, int*>();  // false
    print_is_same<int, int**>(); // false
 
    print_separator();
 
    print_is_same<int, std::remove_pointer<int>::type>();   // true
    print_is_same<int, std::remove_pointer<int*>::type>();  // true
    print_is_same<int, std::remove_pointer<int**>::type>(); // false
 
    print_separator();
 
    print_is_same<int, std::remove_pointer<int* const>::type>();          // true
    print_is_same<int, std::remove_pointer<int* volatile>::type>();       // true
    print_is_same<int, std::remove_pointer<int* const volatile>::type>(); // true
}

二次

产出:

二次

代码语言:javascript
复制
true
false
false
-----
true
true
false
-----
true
true
true

二次

另见

is_pointer (C++11)

checks if a type is a pointer type (class template)

add_pointer (C++11)

adds pointer to the given type (class template)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券