下面的结果是什么?它是格式错误、未定义的行为还是定义良好且格式正确的行为?
struct A {};
std::pointer_traits<A> x;
我之所以问,是因为好奇想知道,也想知道任意类型是不是指针。我还想包括 shared_ptr 和 friend 。我想知道是否有类型特征(谓词),如果没有,我是否可以使用 pointer_traits 并检测是否声明了 element_type。
最佳答案
它表示从 20.6.3p1 开始格式错误,因为它没有 element_type
并且不是类模板实例化
typedef see below element_type;
Type: Ptr::element_type if such a type exists; otherwise, T if Ptr is a class template instantiation of the form
SomePointer<T, Args>
, where Args is zero or more type arguments; otherwise, the specialization is ill-formed.
关于c++ - pointer_traits 为既不是 X<A, T...> 也没有提供成员 typedef element_type 的类型提供什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15349326/