[libcxx-commits] [libcxx] [libc++] Implement the `indirect` half of P3019R14: Vocabulary Types for Composite Class Design (PR #166717)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 6 08:18:02 PST 2025


================
@@ -0,0 +1,339 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_INDIRECT_H
+#define _LIBCPP___MEMORY_INDIRECT_H
+
+#include <__config>
+
+#include <__compare/strong_order.h>
+#include <__compare/synth_three_way.h>
+#include <__functional/hash.h>
+#include <__fwd/memory_resource.h>
+#include <__memory/addressof.h>
+#include <__memory/allocation_guard.h>
+#include <__memory/allocator_arg_t.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/swap_allocator.h>
+#include <__type_traits/is_array.h>
+#include <__type_traits/is_assignable.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_cv.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/exchange.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include <__utility/swap.h>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER >= 26
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Allocator = allocator<_Tp>>
+class _LIBCPP_NO_SPECIALIZATIONS indirect {
+public:
+  using value_type     = _Tp;
+  using allocator_type = _Allocator;
+  using pointer        = allocator_traits<_Allocator>::pointer;
+  using const_pointer  = allocator_traits<_Allocator>::const_pointer;
+
+  static_assert(__check_valid_allocator<allocator_type>::value);
+  static_assert(is_same_v<typename allocator_type::value_type, value_type>);
+  static_assert(is_object_v<value_type>);
+  static_assert(!is_array_v<value_type>);
+  static_assert(!is_same_v<value_type, in_place_t>);
+  static_assert(!__is_inplace_type<value_type>::value);
+  static_assert(std::is_same_v<value_type, remove_cv_t<value_type>>,
+                "value_type must not be const or volatile qualified");
----------------
philnik777 wrote:

Could you add some explanations to these?

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


More information about the libcxx-commits mailing list