Skip to content

[libc++] Implement std::inplace_vector<T, N> #105981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/docs/FeatureTestMacroTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_hazard_pointer`` *unimplemented*
---------------------------------------------------------- -----------------
``__cpp_lib_inplace_vector`` *unimplemented*
``__cpp_lib_inplace_vector`` ``202406L``
---------------------------------------------------------- -----------------
``__cpp_lib_is_virtual_base_of`` ``202406L``
---------------------------------------------------------- -----------------
Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx2cPapers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"`P3168R2 <https://wg21.link/P3168R2>`__","Give ``std::optional`` Range Support","2024-06 (St. Louis)","","",""
"`P3217R0 <https://wg21.link/P3217R0>`__","Adjoints to 'Enabling list-initialization for algorithms': find_last","2024-06 (St. Louis)","","",""
"`P2985R0 <https://wg21.link/P2985R0>`__","A type trait for detecting virtual base classes","2024-06 (St. Louis)","|Complete|","20.0",""
"`P0843R14 <https://wg21.link/P0843R14>`__","``inplace_vector``","2024-06 (St. Louis)","","",""
"`P0843R14 <https://wg21.link/P0843R14>`__","``inplace_vector``","2024-06 (St. Louis)","|Complete|","20.0",""
"`P3235R3 <https://wg21.link/P3235R3>`__","``std::print`` more types faster with less memory","2024-06 (St. Louis)","","",""
"`P2968R2 <https://wg21.link/P2968R2>`__","Make ``std::ignore`` a first-class object","2024-06 (St. Louis)","|Complete|","19.0",""
"`P2075R6 <https://wg21.link/P2075R6>`__","Philox as an extension of the C++ RNG engines","2024-06 (St. Louis)","","",""
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@ set(files
functional
future
initializer_list
inplace_vector
inttypes.h
iomanip
ios
Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/__configuration/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@
//
// Supported containers:
// - `span`;
// - `string_view`.
// - `string_view`;
// - `inplace_vector`.
// #define _LIBCPP_ABI_BOUNDED_ITERATORS

// Changes the iterator type of `basic_string` to a bounded iterator that keeps track of whether it's within the bounds
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/__iterator/wrap_iter.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ class __wrap_iter {
friend class _LIBCPP_TEMPLATE_VIS span;
template <class _Tp, size_t _Size>
friend struct array;
#if _LIBCPP_STD_VER >= 26
template <class _Tp, size_t _Capacity>
friend class inplace_vector;
#endif
};

template <class _Iter1>
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__std_clang_module
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
#include <functional>
#include <future>
#include <initializer_list>
#include <inplace_vector>
#include <inttypes.h>
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
# include <iomanip>
Expand Down
1,091 changes: 1,091 additions & 0 deletions libcxx/include/inplace_vector

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions libcxx/include/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ module std_initializer_list [system] {
header "initializer_list"
export *
}
module std_inplace_vector [system] {
header "inplace_vector"
export *
}
module std_iomanip [system] {
header "iomanip"
export *
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/version
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ __cpp_lib_void_t 201411L <type_traits>
// # define __cpp_lib_function_ref 202306L
// # define __cpp_lib_generate_random 202403L
// # define __cpp_lib_hazard_pointer 202306L
// # define __cpp_lib_inplace_vector 202406L
# define __cpp_lib_inplace_vector 202406L
# if __has_builtin(__builtin_is_virtual_base_of)
# define __cpp_lib_is_virtual_base_of 202406L
# endif
Expand Down
1 change: 1 addition & 0 deletions libcxx/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ set(LIBCXX_MODULE_STD_SOURCES
std/generator.inc
std/hazard_pointer.inc
std/initializer_list.inc
std/inplace_vector.inc
std/iomanip.inc
std/ios.inc
std/iosfwd.inc
Expand Down
3 changes: 0 additions & 3 deletions libcxx/modules/std.compat.cppm.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ module;
# if __has_include(<hazard_pointer>)
# error "please update the header information for <hazard_pointer> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<hazard_pointer>)
# if __has_include(<inplace_vector>)
# error "please update the header information for <inplace_vector> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<inplace_vector>)
# if __has_include(<linalg>)
# error "please update the header information for <linalg> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<linalg>)
Expand Down
4 changes: 1 addition & 3 deletions libcxx/modules/std.cppm.in
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ module;
#include <functional>
#include <future>
#include <initializer_list>
#include <inplace_vector>
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
# include <iomanip>
#endif
Expand Down Expand Up @@ -173,9 +174,6 @@ module;
# if __has_include(<hazard_pointer>)
# error "please update the header information for <hazard_pointer> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<hazard_pointer>)
# if __has_include(<inplace_vector>)
# error "please update the header information for <inplace_vector> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<inplace_vector>)
# if __has_include(<linalg>)
# error "please update the header information for <linalg> in headers_not_available in utils/libcxx/header_information.py"
# endif // __has_include(<linalg>)
Expand Down
19 changes: 19 additions & 0 deletions libcxx/modules/std/inplace_vector.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// -*- 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
//
//===----------------------------------------------------------------------===//

export namespace std {

// [inplace.vector], class template inplace_vector
using std::inplace_vector;

// [inplace.vector.erasure], erasure
using std::erase;
using std::erase_if;

} // namespace std
17 changes: 17 additions & 0 deletions libcxx/test/libcxx/transitive_includes/cxx03.csv
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,23 @@ future vector
future version
initializer_list cstddef
initializer_list version
inplace_vector cctype
inplace_vector cmath
inplace_vector compare
inplace_vector cstddef
inplace_vector cstdint
inplace_vector cstdlib
inplace_vector cwchar
inplace_vector cwctype
inplace_vector exception
inplace_vector initializer_list
inplace_vector iosfwd
inplace_vector limits
inplace_vector new
inplace_vector stdexcept
inplace_vector type_traits
inplace_vector typeinfo
inplace_vector version
iomanip algorithm
iomanip array
iomanip atomic
Expand Down
17 changes: 17 additions & 0 deletions libcxx/test/libcxx/transitive_includes/cxx11.csv
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,23 @@ future vector
future version
initializer_list cstddef
initializer_list version
inplace_vector cctype
inplace_vector cmath
inplace_vector compare
inplace_vector cstddef
inplace_vector cstdint
inplace_vector cstdlib
inplace_vector cwchar
inplace_vector cwctype
inplace_vector exception
inplace_vector initializer_list
inplace_vector iosfwd
inplace_vector limits
inplace_vector new
inplace_vector stdexcept
inplace_vector type_traits
inplace_vector typeinfo
inplace_vector version
iomanip algorithm
iomanip array
iomanip atomic
Expand Down
17 changes: 17 additions & 0 deletions libcxx/test/libcxx/transitive_includes/cxx14.csv
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,23 @@ future vector
future version
initializer_list cstddef
initializer_list version
inplace_vector cctype
inplace_vector cmath
inplace_vector compare
inplace_vector cstddef
inplace_vector cstdint
inplace_vector cstdlib
inplace_vector cwchar
inplace_vector cwctype
inplace_vector exception
inplace_vector initializer_list
inplace_vector iosfwd
inplace_vector limits
inplace_vector new
inplace_vector stdexcept
inplace_vector type_traits
inplace_vector typeinfo
inplace_vector version
iomanip algorithm
iomanip array
iomanip atomic
Expand Down
17 changes: 17 additions & 0 deletions libcxx/test/libcxx/transitive_includes/cxx17.csv
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,23 @@ future vector
future version
initializer_list cstddef
initializer_list version
inplace_vector cctype
inplace_vector cmath
inplace_vector compare
inplace_vector cstddef
inplace_vector cstdint
inplace_vector cstdlib
inplace_vector cwchar
inplace_vector cwctype
inplace_vector exception
inplace_vector initializer_list
inplace_vector iosfwd
inplace_vector limits
inplace_vector new
inplace_vector stdexcept
inplace_vector type_traits
inplace_vector typeinfo
inplace_vector version
iomanip algorithm
iomanip array
iomanip atomic
Expand Down
17 changes: 17 additions & 0 deletions libcxx/test/libcxx/transitive_includes/cxx20.csv
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,23 @@ future vector
future version
initializer_list cstddef
initializer_list version
inplace_vector cctype
inplace_vector cmath
inplace_vector compare
inplace_vector cstddef
inplace_vector cstdint
inplace_vector cstdlib
inplace_vector cwchar
inplace_vector cwctype
inplace_vector exception
inplace_vector initializer_list
inplace_vector iosfwd
inplace_vector limits
inplace_vector new
inplace_vector stdexcept
inplace_vector type_traits
inplace_vector typeinfo
inplace_vector version
iomanip algorithm
iomanip array
iomanip atomic
Expand Down
11 changes: 11 additions & 0 deletions libcxx/test/libcxx/transitive_includes/cxx23.csv
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,17 @@ future typeinfo
future version
initializer_list cstddef
initializer_list version
inplace_vector cctype
inplace_vector compare
inplace_vector cstddef
inplace_vector cstdint
inplace_vector cwchar
inplace_vector cwctype
inplace_vector initializer_list
inplace_vector limits
inplace_vector new
inplace_vector stdexcept
inplace_vector version
iomanip bitset
iomanip cctype
iomanip cerrno
Expand Down
11 changes: 11 additions & 0 deletions libcxx/test/libcxx/transitive_includes/cxx26.csv
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,17 @@ future typeinfo
future version
initializer_list cstddef
initializer_list version
inplace_vector cctype
inplace_vector compare
inplace_vector cstddef
inplace_vector cstdint
inplace_vector cwchar
inplace_vector cwctype
inplace_vector initializer_list
inplace_vector limits
inplace_vector new
inplace_vector stdexcept
inplace_vector version
iomanip bitset
iomanip cctype
iomanip cerrno
Expand Down
Loading
Loading