[libcxx-commits] [libcxx] [String] Allow fancy pointer as pointer type of basic_string allocator (PR #191023)

Nikita Belenkiy via libcxx-commits libcxx-commits at lists.llvm.org
Sat Apr 11 05:08:18 PDT 2026


================
@@ -444,6 +445,235 @@ TEST_CONSTEXPR_CXX20 thread_unsafe_shared_ptr<T> make_thread_unsafe_shared(Args.
 }
 } // namespace detail
 
+template <class T>
+class fancy_pointer {
+public:
+  // For the std::pointer_traits interface.
+  using pointer         = T*;
+  using element_type    = T;
+  using difference_type = std::ptrdiff_t;
+
+  template <class U>
+  using rebind = fancy_pointer<U>;
+
+  // For the std::iterator_traits interface.
+  using value_type        = typename std::remove_cv<T>::type;
+  using reference         = typename std::add_lvalue_reference<T>::type;
+  using iterator_category = std::random_access_iterator_tag;
+
+  TEST_CONSTEXPR_CXX14 fancy_pointer() TEST_NOEXCEPT : ptr_(nullptr) {}
----------------
kitsnet wrote:

I think the original use was copied from `min_allocator`. Our tests only have static asserts for TEST_STD_VER > 17 (at least for string tests), so at least technically we can.
However, there are two approaches to such specifiers.  One is to show intended usage, the other one is to satisfy linters. Will we soon have `modernize-use-constexpr` in clang-tidy?

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


More information about the libcxx-commits mailing list