std::to_address implementation and std::pointer_traits's static_assert

Ion Gaztañaga igaztanaga@gmail.com
Tue Apr 20 13:34:24 GMT 2021


Hi,

While trying to add contiguous_iterator support for Boost.Container so 
that users can use std::span with boost::container::vector, I've found a 
possible issue with libstdc++  (not sure about it) triggered when 
evaluating the "std::contiguous_iterator" concept.

According to the standard, "std::to_address" should evaluate if 
"std::pointer_traits<Ptr>::to_address(p)" is well-formed and call 
"std::to_address(p.operator->())" if it is not. However, if "Ptr" does 
not define "element_type", std::pointer_traits's static assert triggers:

static_assert(!is_same<element_type, __undefined>::value, "...");


which makes std::pointer_traits sfinae-unfriendly. The standard says 
that if element_type can't be deduced, pointer_traits specialization is 
ill-formed but I expected that std::to_address would select the 
"operator->" way of obtaining the address. Is my expectation correct?

Many thanks,

Ion


More information about the Libstdc++ mailing list