What is the result of following? Is it illformed, undefined behavior or welldefined and wellformed?
struct A {};
std::pointer_traits<A> x;
The reason I ask is because I want to know for curiousity, and because I want to know whether an arbitrary type is a pointer. With that I also mean to include shared_ptr and friends. I wondered whether there is a type trait (predicate) for that or, if not, whether I can use pointer_traits and detect whether element_type is declared or not.
It says it is ill-formed as from 20.6.3p1 since it doesn't have element_type
and is not a class template instantiation
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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.