Skip to content

Commit 440c327

Browse files
committed
[libc++] Implement std::inplace_vector<T, N>
1 parent 07e0b8a commit 440c327

File tree

107 files changed

+7563
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+7563
-23
lines changed

libcxx/docs/FeatureTestMacroTable.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ Status
442442
---------------------------------------------------------- -----------------
443443
``__cpp_lib_hazard_pointer`` *unimplemented*
444444
---------------------------------------------------------- -----------------
445-
``__cpp_lib_inplace_vector`` *unimplemented*
445+
``__cpp_lib_inplace_vector`` ``202406L``
446446
---------------------------------------------------------- -----------------
447447
``__cpp_lib_is_virtual_base_of`` ``202406L``
448448
---------------------------------------------------------- -----------------

libcxx/docs/Status/Cxx2cPapers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"`P3168R2 <https://wg21.link/P3168R2>`__","Give ``std::optional`` Range Support","2024-06 (St. Louis)","","",""
7070
"`P3217R0 <https://wg21.link/P3217R0>`__","Adjoints to 'Enabling list-initialization for algorithms': find_last","2024-06 (St. Louis)","","",""
7171
"`P2985R0 <https://wg21.link/P2985R0>`__","A type trait for detecting virtual base classes","2024-06 (St. Louis)","|Complete|","20.0",""
72-
"`P0843R14 <https://wg21.link/P0843R14>`__","``inplace_vector``","2024-06 (St. Louis)","","",""
72+
"`P0843R14 <https://wg21.link/P0843R14>`__","``inplace_vector``","2024-06 (St. Louis)","|Complete|","20.0",""
7373
"`P3235R3 <https://wg21.link/P3235R3>`__","``std::print`` more types faster with less memory","2024-06 (St. Louis)","","",""
7474
"`P2968R2 <https://wg21.link/P2968R2>`__","Make ``std::ignore`` a first-class object","2024-06 (St. Louis)","|Complete|","19.0",""
7575
"`P2075R6 <https://wg21.link/P2075R6>`__","Philox as an extension of the C++ RNG engines","2024-06 (St. Louis)","","",""

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ set(files
955955
functional
956956
future
957957
initializer_list
958+
inplace_vector
958959
inttypes.h
959960
iomanip
960961
ios

libcxx/include/__configuration/abi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@
160160
//
161161
// Supported containers:
162162
// - `span`;
163-
// - `string_view`.
163+
// - `string_view`;
164+
// - `inplace_vector`.
164165
// #define _LIBCPP_ABI_BOUNDED_ITERATORS
165166

166167
// Changes the iterator type of `basic_string` to a bounded iterator that keeps track of whether it's within the bounds

libcxx/include/__iterator/wrap_iter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ class __wrap_iter {
108108
friend class _LIBCPP_TEMPLATE_VIS span;
109109
template <class _Tp, size_t _Size>
110110
friend struct array;
111+
#if _LIBCPP_STD_VER >= 26
112+
template <class _Tp, size_t _Capacity>
113+
friend class inplace_vector;
114+
#endif
111115
};
112116

113117
template <class _Iter1>

libcxx/include/__std_clang_module

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
#include <functional>
9898
#include <future>
9999
#include <initializer_list>
100+
#include <inplace_vector>
100101
#include <inttypes.h>
101102
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
102103
# include <iomanip>

libcxx/include/inplace_vector

Lines changed: 1091 additions & 0 deletions
Large diffs are not rendered by default.

libcxx/include/module.modulemap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ module std_initializer_list [system] {
140140
header "initializer_list"
141141
export *
142142
}
143+
module std_inplace_vector [system] {
144+
header "inplace_vector"
145+
export *
146+
}
143147
module std_iomanip [system] {
144148
header "iomanip"
145149
export *

libcxx/include/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ __cpp_lib_void_t 201411L <type_traits>
535535
// # define __cpp_lib_function_ref 202306L
536536
// # define __cpp_lib_generate_random 202403L
537537
// # define __cpp_lib_hazard_pointer 202306L
538-
// # define __cpp_lib_inplace_vector 202406L
538+
# define __cpp_lib_inplace_vector 202406L
539539
# if __has_builtin(__builtin_is_virtual_base_of)
540540
# define __cpp_lib_is_virtual_base_of 202406L
541541
# endif

libcxx/modules/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ set(LIBCXX_MODULE_STD_SOURCES
5252
std/generator.inc
5353
std/hazard_pointer.inc
5454
std/initializer_list.inc
55+
std/inplace_vector.inc
5556
std/iomanip.inc
5657
std/ios.inc
5758
std/iosfwd.inc

libcxx/modules/std.compat.cppm.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ module;
6565
# if __has_include(<hazard_pointer>)
6666
# error "please update the header information for <hazard_pointer> in headers_not_available in utils/libcxx/header_information.py"
6767
# endif // __has_include(<hazard_pointer>)
68-
# if __has_include(<inplace_vector>)
69-
# error "please update the header information for <inplace_vector> in headers_not_available in utils/libcxx/header_information.py"
70-
# endif // __has_include(<inplace_vector>)
7168
# if __has_include(<linalg>)
7269
# error "please update the header information for <linalg> in headers_not_available in utils/libcxx/header_information.py"
7370
# endif // __has_include(<linalg>)

libcxx/modules/std.cppm.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ module;
7272
#include <functional>
7373
#include <future>
7474
#include <initializer_list>
75+
#include <inplace_vector>
7576
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
7677
# include <iomanip>
7778
#endif
@@ -173,9 +174,6 @@ module;
173174
# if __has_include(<hazard_pointer>)
174175
# error "please update the header information for <hazard_pointer> in headers_not_available in utils/libcxx/header_information.py"
175176
# endif // __has_include(<hazard_pointer>)
176-
# if __has_include(<inplace_vector>)
177-
# error "please update the header information for <inplace_vector> in headers_not_available in utils/libcxx/header_information.py"
178-
# endif // __has_include(<inplace_vector>)
179177
# if __has_include(<linalg>)
180178
# error "please update the header information for <linalg> in headers_not_available in utils/libcxx/header_information.py"
181179
# endif // __has_include(<linalg>)

libcxx/modules/std/inplace_vector.inc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
export namespace std {
11+
12+
// [inplace.vector], class template inplace_vector
13+
using std::inplace_vector;
14+
15+
// [inplace.vector.erasure], erasure
16+
using std::erase;
17+
using std::erase_if;
18+
19+
} // namespace std

libcxx/test/libcxx/transitive_includes/cxx03.csv

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,23 @@ future vector
938938
future version
939939
initializer_list cstddef
940940
initializer_list version
941+
inplace_vector cctype
942+
inplace_vector cmath
943+
inplace_vector compare
944+
inplace_vector cstddef
945+
inplace_vector cstdint
946+
inplace_vector cstdlib
947+
inplace_vector cwchar
948+
inplace_vector cwctype
949+
inplace_vector exception
950+
inplace_vector initializer_list
951+
inplace_vector iosfwd
952+
inplace_vector limits
953+
inplace_vector new
954+
inplace_vector stdexcept
955+
inplace_vector type_traits
956+
inplace_vector typeinfo
957+
inplace_vector version
941958
iomanip algorithm
942959
iomanip array
943960
iomanip atomic

libcxx/test/libcxx/transitive_includes/cxx11.csv

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,23 @@ future vector
938938
future version
939939
initializer_list cstddef
940940
initializer_list version
941+
inplace_vector cctype
942+
inplace_vector cmath
943+
inplace_vector compare
944+
inplace_vector cstddef
945+
inplace_vector cstdint
946+
inplace_vector cstdlib
947+
inplace_vector cwchar
948+
inplace_vector cwctype
949+
inplace_vector exception
950+
inplace_vector initializer_list
951+
inplace_vector iosfwd
952+
inplace_vector limits
953+
inplace_vector new
954+
inplace_vector stdexcept
955+
inplace_vector type_traits
956+
inplace_vector typeinfo
957+
inplace_vector version
941958
iomanip algorithm
942959
iomanip array
943960
iomanip atomic

libcxx/test/libcxx/transitive_includes/cxx14.csv

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,23 @@ future vector
961961
future version
962962
initializer_list cstddef
963963
initializer_list version
964+
inplace_vector cctype
965+
inplace_vector cmath
966+
inplace_vector compare
967+
inplace_vector cstddef
968+
inplace_vector cstdint
969+
inplace_vector cstdlib
970+
inplace_vector cwchar
971+
inplace_vector cwctype
972+
inplace_vector exception
973+
inplace_vector initializer_list
974+
inplace_vector iosfwd
975+
inplace_vector limits
976+
inplace_vector new
977+
inplace_vector stdexcept
978+
inplace_vector type_traits
979+
inplace_vector typeinfo
980+
inplace_vector version
964981
iomanip algorithm
965982
iomanip array
966983
iomanip atomic

libcxx/test/libcxx/transitive_includes/cxx17.csv

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,23 @@ future vector
962962
future version
963963
initializer_list cstddef
964964
initializer_list version
965+
inplace_vector cctype
966+
inplace_vector cmath
967+
inplace_vector compare
968+
inplace_vector cstddef
969+
inplace_vector cstdint
970+
inplace_vector cstdlib
971+
inplace_vector cwchar
972+
inplace_vector cwctype
973+
inplace_vector exception
974+
inplace_vector initializer_list
975+
inplace_vector iosfwd
976+
inplace_vector limits
977+
inplace_vector new
978+
inplace_vector stdexcept
979+
inplace_vector type_traits
980+
inplace_vector typeinfo
981+
inplace_vector version
965982
iomanip algorithm
966983
iomanip array
967984
iomanip atomic

libcxx/test/libcxx/transitive_includes/cxx20.csv

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,23 @@ future vector
948948
future version
949949
initializer_list cstddef
950950
initializer_list version
951+
inplace_vector cctype
952+
inplace_vector cmath
953+
inplace_vector compare
954+
inplace_vector cstddef
955+
inplace_vector cstdint
956+
inplace_vector cstdlib
957+
inplace_vector cwchar
958+
inplace_vector cwctype
959+
inplace_vector exception
960+
inplace_vector initializer_list
961+
inplace_vector iosfwd
962+
inplace_vector limits
963+
inplace_vector new
964+
inplace_vector stdexcept
965+
inplace_vector type_traits
966+
inplace_vector typeinfo
967+
inplace_vector version
951968
iomanip algorithm
952969
iomanip array
953970
iomanip atomic

libcxx/test/libcxx/transitive_includes/cxx23.csv

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,17 @@ future typeinfo
517517
future version
518518
initializer_list cstddef
519519
initializer_list version
520+
inplace_vector cctype
521+
inplace_vector compare
522+
inplace_vector cstddef
523+
inplace_vector cstdint
524+
inplace_vector cwchar
525+
inplace_vector cwctype
526+
inplace_vector initializer_list
527+
inplace_vector limits
528+
inplace_vector new
529+
inplace_vector stdexcept
530+
inplace_vector version
520531
iomanip bitset
521532
iomanip cctype
522533
iomanip cerrno

libcxx/test/libcxx/transitive_includes/cxx26.csv

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,17 @@ future typeinfo
516516
future version
517517
initializer_list cstddef
518518
initializer_list version
519+
inplace_vector cctype
520+
inplace_vector compare
521+
inplace_vector cstddef
522+
inplace_vector cstdint
523+
inplace_vector cwchar
524+
inplace_vector cwctype
525+
inplace_vector initializer_list
526+
inplace_vector limits
527+
inplace_vector new
528+
inplace_vector stdexcept
529+
inplace_vector version
519530
iomanip bitset
520531
iomanip cctype
521532
iomanip cerrno

0 commit comments

Comments
 (0)