![]() |
deal.II version GIT relicensing-6960-g70e9c5b7be 2026-10-22 20:10:01+00:00
|
#include <deal.II/base/std_cxx26/inplace_vector.h>
C++17-implementation of a subset of std::inplace_vector.
Differences:
unsigned short, which is typically 65535.Furthermore, copy and move constructors, copy and move assignment operators, and the destructor are only trivial if both T is trivial for that function and C++20 is available, since declaring this property for a user-defined class requires concepts.
See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2747r2.html for more information.
Definition at line 77 of file inplace_vector.h.
Classes | |
| class | SingleInputIterator |
Public Types | |
| using | value_type = T |
| using | size_type = std::size_t |
| using | difference_type = std::ptrdiff_t |
| using | reference = value_type & |
| using | const_reference = const value_type & |
| using | pointer = value_type * |
| using | const_pointer = const value_type * |
| using | iterator = pointer |
| using | const_iterator = const_pointer |
| using | reverse_iterator = std::reverse_iterator< iterator > |
| using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
Public Member Functions | |
| inplace_vector (size_type n) | |
| inplace_vector (size_type n, const T &value) | |
| template<class InputIterator > | |
| inplace_vector (InputIterator first, InputIterator last) | |
| inplace_vector (const inplace_vector &other) noexcept(std::is_nothrow_copy_constructible_v< T >) | |
| inplace_vector (inplace_vector &&other) noexcept(std::is_nothrow_move_constructible_v< T >) | |
| constexpr | inplace_vector (std::initializer_list< T > init) |
| inplace_vector & | operator= (const inplace_vector &other) |
| inplace_vector & | operator= (inplace_vector &&other) noexcept(std::is_nothrow_move_assignable_v< T > &&std::is_nothrow_move_constructible_v< T >) |
| inplace_vector & | operator= (std::initializer_list< T > init) |
| template<class InputIterator > | |
| void | assign (InputIterator first, InputIterator last) |
| void | assign (size_type n, const T &value) |
| void | assign (std::initializer_list< T > init) |
| constexpr iterator | begin () noexcept |
| constexpr iterator | end () noexcept |
| constexpr const_iterator | begin () const noexcept |
| constexpr const_iterator | end () const noexcept |
| constexpr reverse_iterator | rbegin () noexcept |
| constexpr reverse_iterator | rend () noexcept |
| constexpr const_reverse_iterator | rbegin () const noexcept |
| constexpr const_reverse_iterator | rend () const noexcept |
| constexpr const_iterator | cbegin () const noexcept |
| constexpr const_iterator | cend () const noexcept |
| constexpr const_reverse_iterator | crbegin () const noexcept |
| constexpr const_reverse_iterator | crend () const noexcept |
| reference | operator[] (size_type n) |
| const_reference | operator[] (size_type n) const |
| reference | at (size_type n) |
| const_reference | at (size_type n) const |
| reference | front () |
| const_reference | front () const |
| reference | back () |
| const_reference | back () const |
| T * | data () noexcept |
| const T * | data () const noexcept |
Private Types | |
| using | buffer_size_type = std::conditional_t< N<=std::numeric_limits< std::uint8_t >::max(), std::uint8_t, std::uint16_t > |
Private Member Functions | |
| template<bool check = false, typename... Args> | |
| constexpr void | internal_resize (const size_type n, Args &&...args) noexcept(!check) |
| template<typename InputIterator , bool check = false, bool move = false> | |
| void | internal_assign (InputIterator first, InputIterator last) noexcept(!check &&(move ? std::is_nothrow_move_assignable_v< T > :std::is_nothrow_copy_assignable_v< T >)) |
| template<typename InputIterator , bool check = false, bool move = false> | |
| constexpr size_type | internal_append (InputIterator first, InputIterator last) noexcept(!check &&(move ? std::is_nothrow_move_constructible_v< T > :std::is_nothrow_copy_constructible_v< T >)) |
Private Attributes | ||
| union { | ||
| T elements [N > 0 ? N :1] | ||
| }; | ||
| buffer_size_type | n_elements | |
Related Symbols | |
(Note that these are not member symbols.) | |
| template<typename T , std::size_t N, typename U = T> | |
| std::size_t | erase (std_cxx26::inplace_vector< T, N > &vec, const U &value) |
| template<typename T , std::size_t N, typename Predicate > | |
| std::size_t | erase_if (std_cxx26::inplace_vector< T, N > &vec, Predicate pred) |
| template<typename T , std::size_t N> | |
| bool | operator== (const inplace_vector< T, N > &a, const inplace_vector< T, N > &b) |
| template<typename T , std::size_t N> | |
| bool | operator!= (const inplace_vector< T, N > &a, const inplace_vector< T, N > &b) |
| template<typename T , std::size_t N> | |
| bool | operator< (const inplace_vector< T, N > &a, const inplace_vector< T, N > &b) |
| template<typename T , std::size_t N> | |
| bool | operator> (const inplace_vector< T, N > &a, const inplace_vector< T, N > &b) |
| template<typename T , std::size_t N> | |
| bool | operator<= (const inplace_vector< T, N > &a, const inplace_vector< T, N > &b) |
| template<typename T , std::size_t N> | |
| bool | operator>= (const inplace_vector< T, N > &a, const inplace_vector< T, N > &b) |
| constexpr bool | empty () const noexcept |
| constexpr size_type | size () const noexcept |
| void | resize (size_type n) |
| void | resize (size_type n, const T &value) |
| static constexpr size_type | max_size () noexcept |
| static constexpr size_type | capacity () noexcept |
| static constexpr void | reserve (size_type n) |
| static constexpr void | shrink_to_fit () noexcept |
| template<class... Args> | |
| reference | emplace_back (Args &&...args) |
| reference | push_back (const T &value) |
| reference | push_back (T &&value) |
| void | pop_back () |
| template<class... Args> | |
| reference | unchecked_emplace_back (Args &&...args) |
| reference | unchecked_push_back (const T &value) |
| reference | unchecked_push_back (T &&value) |
| template<class... Args> | |
| iterator | emplace (const_iterator position, Args &&...args) |
| iterator | insert (const_iterator position, const T &value) |
| iterator | insert (const_iterator position, T &&value) |
| iterator | insert (const_iterator position, size_type n, const T &value) |
| template<typename InputIterator > | |
| iterator | insert (const_iterator position, InputIterator first, InputIterator last) |
| iterator | insert (const_iterator position, std::initializer_list< T > init) |
| iterator | erase (const_iterator position) |
| iterator | erase (const_iterator first, const_iterator last) |
| void | swap (inplace_vector &other) noexcept(std::is_nothrow_swappable_v< T > &&std::is_nothrow_move_constructible_v< T >) |
| constexpr void | clear () noexcept |
| void | swap (inplace_vector &x, inplace_vector &y) noexcept(std::is_nothrow_swappable_v< T > &&std::is_nothrow_move_constructible_v< T >) |
| using std_cxx26::inplace_vector< T, N >::value_type = T |
Types.
Definition at line 84 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::size_type = std::size_t |
Definition at line 85 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::difference_type = std::ptrdiff_t |
Definition at line 86 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::reference = value_type & |
Definition at line 87 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::const_reference = const value_type & |
Definition at line 88 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::pointer = value_type * |
Definition at line 89 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::const_pointer = const value_type * |
Definition at line 90 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::iterator = pointer |
Definition at line 91 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::const_iterator = const_pointer |
Definition at line 92 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::reverse_iterator = std::reverse_iterator<iterator> |
Definition at line 94 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Definition at line 95 of file inplace_vector.h.
|
private |
Definition at line 1075 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constructors and destructor. Default constructor.
Definition at line 106 of file inplace_vector.h.
|
inlineexplicit |
Constructor which default initializes n objects.
Definition at line 113 of file inplace_vector.h.
|
inline |
Constructor which creates n objects by copying value.
Definition at line 122 of file inplace_vector.h.
|
inline |
Constructor which copies an iterator range.
Definition at line 135 of file inplace_vector.h.
|
inlinenoexcept |
Copy constructor.
Definition at line 159 of file inplace_vector.h.
|
inlinenoexcept |
Move constructor.
Definition at line 178 of file inplace_vector.h.
|
inlineconstexpr |
Copy constructor from an initializer list.
Definition at line 188 of file inplace_vector.h.
|
inline |
Definition at line 211 of file inplace_vector.h.
|
inline |
Assignment operators. Trivial copy assignment operator. Requires C++20. Copy assignment operator.
Definition at line 238 of file inplace_vector.h.
|
inlinenoexcept |
Move assignment operator.
Definition at line 262 of file inplace_vector.h.
|
inline |
Copy assignment operator (from an initializer list).
Definition at line 276 of file inplace_vector.h.
|
inline |
Assignment functions. Assign the contents of the vector to values in the input iterator range.
Definition at line 297 of file inplace_vector.h.
|
inline |
Assign the contents of the vector to n copies of value.
Definition at line 309 of file inplace_vector.h.
|
inline |
Assign the contents of the vector to values in the initializer list.
Definition at line 322 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Iterators. Begin iterator.
Definition at line 339 of file inplace_vector.h.
|
inlineconstexprnoexcept |
End iterator.
Definition at line 348 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant begin iterator.
Definition at line 357 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant end iterator.
Definition at line 366 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Reverse begin iterator.
Definition at line 375 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Reverse end iterator.
Definition at line 384 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant reverse begin iterator.
Definition at line 393 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant reverse end iterator.
Definition at line 402 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant begin iterator.
Definition at line 411 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant end iterator.
Definition at line 420 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant reverse begin iterator.
Definition at line 429 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant reverse end iterator.
Definition at line 438 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Capacity. Return whether or not the vector contains any objects.
Definition at line 452 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Return the number of objects in the vector.
Definition at line 461 of file inplace_vector.h.
|
inlinestaticconstexprnoexcept |
Maximum possible size of the vector.
Definition at line 471 of file inplace_vector.h.
|
inlinestaticconstexprnoexcept |
Maximum possible capacity of the vector.
Definition at line 480 of file inplace_vector.h.
|
inline |
Resize the vector to have n objects.
Definition at line 489 of file inplace_vector.h.
|
inline |
Resize the vector to have n objects by constructing new objects with copies of value.
Definition at line 499 of file inplace_vector.h.
|
inlinestaticconstexpr |
If \(n > N\) then throw an exception. This function exists for compatibility with other containers but, since this vector has a fixed internal storage size, calling this function does not affect the object in any way.
Definition at line 511 of file inplace_vector.h.
|
inlinestaticconstexprnoexcept |
This function does nothing for inplace_vector and exists for compatibility with other containers.
Definition at line 522 of file inplace_vector.h.
|
inline |
Element access. Return a reference to the n-th element.
Definition at line 535 of file inplace_vector.h.
|
inline |
Return a constant reference to the n-th element.
Definition at line 545 of file inplace_vector.h.
|
inline |
If \(n\) is less than size() then return a reference to the n-th element: otherwise throw an exception.
Definition at line 556 of file inplace_vector.h.
|
inline |
If \(n\) is less than size() then return a constant reference to the n-th element: otherwise throw an exception.
Definition at line 569 of file inplace_vector.h.
|
inline |
Return a reference to the first object in the vector.
Definition at line 581 of file inplace_vector.h.
|
inline |
Return a constant reference to the first object in the vector.
Definition at line 591 of file inplace_vector.h.
|
inline |
Return a reference to the last object in the vector.
Definition at line 601 of file inplace_vector.h.
|
inline |
Return a constant reference to the last object in the vector.
Definition at line 611 of file inplace_vector.h.
|
inlinenoexcept |
Data access. Return a pointer to all objects in the vector.
Definition at line 629 of file inplace_vector.h.
|
inlinenoexcept |
Return a constant pointer to all objects in the vector.
Definition at line 640 of file inplace_vector.h.
|
inline |
Modifiers. Construct a new object at the end of the vector by forwarding all arguments to its constructor.
Definition at line 660 of file inplace_vector.h.
|
inline |
Construct a new object at the end of the vector by copying value.
Definition at line 673 of file inplace_vector.h.
|
inline |
Construct a new object at the end of the vector by moving value.
Definition at line 686 of file inplace_vector.h.
|
inline |
Destruct the last object in the vector and reduce the size of this object by one.
Definition at line 697 of file inplace_vector.h.
|
inline |
Construct a new object at the end of the vector by forwarding all objects to its constructor.
Definition at line 712 of file inplace_vector.h.
|
inline |
Construct a new object at the end of the vector by copying value.
Definition at line 726 of file inplace_vector.h.
|
inline |
Construct a new object at the end of the vector by moving value.
Definition at line 740 of file inplace_vector.h.
|
inline |
Construct a new object at the location of position by forwarding all objects (args etc.) to its constructor.
Definition at line 753 of file inplace_vector.h.
|
inline |
Construct a new object at the location of position by copying value.
Definition at line 773 of file inplace_vector.h.
|
inline |
Construct a new object at the location of position by moving value.
Definition at line 782 of file inplace_vector.h.
|
inline |
Construct \(n\) new objects at the location of position by copying value.
Definition at line 791 of file inplace_vector.h.
|
inline |
Construct new objects at the location of position from the iterator range defined by first and last.
Definition at line 804 of file inplace_vector.h.
|
inline |
Insert values from an initializer list at a position.
Definition at line 831 of file inplace_vector.h.
|
inline |
Erase a value.
Definition at line 840 of file inplace_vector.h.
|
inline |
Erase a range of values.
Definition at line 855 of file inplace_vector.h.
|
inlinenoexcept |
Swap the contents of this vector with another.
Definition at line 874 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Clear the contents of the vector.
Definition at line 913 of file inplace_vector.h.
|
inlineconstexprprivatenoexcept |
Common function for resizing the vector.
Definition at line 979 of file inplace_vector.h.
|
inlineprivatenoexcept |
Common function for assigning values to the vector from a range of input iterators, first by copying and then by placement new.
Definition at line 1011 of file inplace_vector.h.
|
inlineconstexprprivatenoexcept |
Common function for creating or moving new values at the end of the vector.
Definition at line 1038 of file inplace_vector.h.
|
friend |
Friend swap function.
Definition at line 903 of file inplace_vector.h.
|
related |
Comparison operators. Equality operator for inplace_vector.
Definition at line 1101 of file inplace_vector.h.
|
related |
Inequality operator for inplace_vector.
Definition at line 1113 of file inplace_vector.h.
|
related |
Less than operator for inplace_vector.
Definition at line 1124 of file inplace_vector.h.
|
related |
Greater than operator for inplace_vector.
Definition at line 1137 of file inplace_vector.h.
|
related |
Less than or equal to operator for inplace_vector.
Definition at line 1148 of file inplace_vector.h.
|
related |
Greater than or equal to operator for inplace_vector.
Definition at line 1161 of file inplace_vector.h.
|
related |
Erase all values equal to value in vec.
Definition at line 1174 of file inplace_vector.h.
|
related |
Erase all values which satisfy the predicate pred in vec.
Definition at line 1190 of file inplace_vector.h.
| T std_cxx26::inplace_vector< T, N >::elements[N > 0 ? N :1] |
Definition at line 1072 of file inplace_vector.h.
| union { ... } std_cxx26::inplace_vector< T, N > |
Prevent initialization of unused elements by placing the array in a union.
|
private |
Present number of elements in the buffer.
Definition at line 1087 of file inplace_vector.h.