[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
Thu Sep 7 11:43:04 PDT 2023
================
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+// Should not require a specialization of pointer_traits for Ptr.
+
+#include <memory>
+
+struct IntPtr {
+ constexpr int* operator->() const { return ptr; }
+
+ int* ptr;
+};
+
----------------
zetafunction wrote:
OK, that's very clever. I added the tests you suggested, as well as some direct tests of pointer_traits themselves.
It seems like rebind and pointer_to aren't SFINAE-friendly either, but I was able to test that pointer_traits for a non-pointer-like type is empty at least.
https://github.com/llvm/llvm-project/pull/65177
More information about the libcxx-commits
mailing list