[libcxx-commits] [libcxx] [libc++] Implement LWG3545: std::pointer_traits should be SFINAE-friendly. (PR #65177)

Daniel Cheng via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 12 16:43:46 PDT 2023


================
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// template <class Ptr> constexpr auto to_address(const Ptr& p) noexcept;
+//     Mandates: one of pointer_traits<Ptr>::to_address() or Ptr::operator->()
+//     is present.
+
+#include <memory>
+
+struct NotPtr {};
+
+void test() {
+  (void)std::to_address(NotPtr()); // expected-error@*:* {{no matching function for call to 'to_address'}}
----------------
zetafunction wrote:

I think this is what @EricWF suggested as well, and I've already incorporated it into libcxx/test/std/utilities/memory/pointer.conversion/to_address_without_pointer_traits.pass.cpp. Were you thinking of something else, or is the suggestion just to move it all into to_address.pass.cpp?

The reason I broke it out separately is because to_address.pass.cpp seemed to be a conglomeration of a bunch of (somewhat random) tests, e.g. "Taken from a build breakage caused in Clang". But if you prefer, I'm happy to fold it all back in.

Should I take this comment to mean that you'd prefer to just delete to_address.verify.cpp altogether?

https://github.com/llvm/llvm-project/pull/65177


More information about the libcxx-commits mailing list