std::add_cv, std::add_const, std::add_volatile std::make_signed std::make_unsigned std::remove_reference std::add_lvalue_reference, std::add_rvalue_reference std::remove_pointer std::add_pointer std::remove_extent std::remove_all_extents std::aligned_storage std::aligned_union std::...
如果T 是可引用类型或(可有 cv 限定的) void,那么提供的成员 typedef type 是typename std::remove_reference<T>::type*。 否则,提供的成员 typedef type 是T。 如果程序添加了 std::add_pointer 的特化,那么行为未定义。 嵌套类型名字 定义 type 按以上方式确定 ...
对于 template<typename T> struct std::add_pointer;如果 T 为 V& 或 V&&,则 type 为 V*…add...
代码示例 // add_pointer#include<iostream>#include<type_traits>typedefstd::add_pointer<int>::type A;// int*typedefstd::add_pointer<constint>::type B;// const int*typedefstd::add_pointer<int&>::type C;// int*typedefstd::add_pointer<int*>::type D;// int**typedefstd::add_pointer<...
#include <iostream> #include <type_traits> int main() { int i = 123; int& ri = i; typedef std::add_pointer<decltype(i)>::type IntPtr; typedef std::add_pointer<decltype(ri)>::type IntPtr2; IntPtr pi = &i; std::cout << "i = " << i << "\n"; std::cout << "*pi...
typedefstd::add_pointer<decltype(i)>::typeIntPtr;typedefstd::add_pointer<decltype(ri)>::typeIntPtr2;IntPtr pi=&i;std::cout<<"i = "<<i<<'\n';std::cout<<"*pi = "<<*pi<<'\n';static_assert(std::is_pointer_v<IntPtr>,"IntPtr should be a pointer");static_assert(std::is...