// { dg-do compile { target c++20 } } #include template struct nttp_ptr { T* operator->() const { return nullptr; } }; // This gives an error in C++20, which the LWG 3545 resolution should fix: auto x = std::to_address( nttp_ptr() ); template struct clever_ptr { static T obj; constexpr T* operator->() const { return &obj; } }; // pointer_traits specialization is valid, but to_address uses operator-> static_assert( std::to_address(clever_ptr{}) == &clever_ptr::obj ); int the_int; template<> struct std::pointer_traits> { using element_type = int; using difference_type = std::ptrdiff_t; using pointer = clever_ptr; static constexpr int* to_address(pointer p) { return &the_int; } }; // Uses pointer_traits>::to_address static_assert( std::to_address(clever_ptr{}) == &the_int );