![]() |
deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20: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 79 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 86 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::size_type = std::size_t |
Definition at line 87 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::difference_type = std::ptrdiff_t |
Definition at line 88 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::reference = value_type & |
Definition at line 89 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::const_reference = const value_type & |
Definition at line 90 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::pointer = value_type * |
Definition at line 91 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::const_pointer = const value_type * |
Definition at line 92 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::iterator = pointer |
Definition at line 93 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::const_iterator = const_pointer |
Definition at line 94 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::reverse_iterator = std::reverse_iterator<iterator> |
Definition at line 96 of file inplace_vector.h.
| using std_cxx26::inplace_vector< T, N >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Definition at line 97 of file inplace_vector.h.
|
private |
Definition at line 1077 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constructors and destructor. Default constructor.
Definition at line 108 of file inplace_vector.h.
|
inlineexplicit |
Constructor which default initializes n objects.
Definition at line 115 of file inplace_vector.h.
|
inline |
Constructor which creates n objects by copying value.
Definition at line 124 of file inplace_vector.h.
|
inline |
Constructor which copies an iterator range.
Definition at line 137 of file inplace_vector.h.
|
inlinenoexcept |
Copy constructor.
Definition at line 161 of file inplace_vector.h.
|
inlinenoexcept |
Move constructor.
Definition at line 180 of file inplace_vector.h.
|
inlineconstexpr |
Copy constructor from an initializer list.
Definition at line 190 of file inplace_vector.h.
|
inline |
Definition at line 213 of file inplace_vector.h.
|
inline |
Assignment operators. Trivial copy assignment operator. Requires C++20. Copy assignment operator.
Definition at line 240 of file inplace_vector.h.
|
inlinenoexcept |
Move assignment operator.
Definition at line 264 of file inplace_vector.h.
|
inline |
Copy assignment operator (from an initializer list).
Definition at line 278 of file inplace_vector.h.
|
inline |
Assignment functions. Assign the contents of the vector to values in the input iterator range.
Definition at line 299 of file inplace_vector.h.
|
inline |
Assign the contents of the vector to n copies of value.
Definition at line 311 of file inplace_vector.h.
|
inline |
Assign the contents of the vector to values in the initializer list.
Definition at line 324 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Iterators. Begin iterator.
Definition at line 341 of file inplace_vector.h.
|
inlineconstexprnoexcept |
End iterator.
Definition at line 350 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant begin iterator.
Definition at line 359 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant end iterator.
Definition at line 368 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Reverse begin iterator.
Definition at line 377 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Reverse end iterator.
Definition at line 386 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant reverse begin iterator.
Definition at line 395 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant reverse end iterator.
Definition at line 404 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant begin iterator.
Definition at line 413 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant end iterator.
Definition at line 422 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant reverse begin iterator.
Definition at line 431 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Constant reverse end iterator.
Definition at line 440 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Capacity. Return whether or not the vector contains any objects.
Definition at line 454 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Return the number of objects in the vector.
Definition at line 463 of file inplace_vector.h.
|
inlinestaticconstexprnoexcept |
Maximum possible size of the vector.
Definition at line 473 of file inplace_vector.h.
|
inlinestaticconstexprnoexcept |
Maximum possible capacity of the vector.
Definition at line 482 of file inplace_vector.h.
|
inline |
Resize the vector to have n objects.
Definition at line 491 of file inplace_vector.h.
|
inline |
Resize the vector to have n objects by constructing new objects with copies of value.
Definition at line 501 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 513 of file inplace_vector.h.
|
inlinestaticconstexprnoexcept |
This function does nothing for inplace_vector and exists for compatibility with other containers.
Definition at line 524 of file inplace_vector.h.
|
inline |
Element access. Return a reference to the n-th element.
Definition at line 537 of file inplace_vector.h.
|
inline |
Return a constant reference to the n-th element.
Definition at line 547 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 558 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 571 of file inplace_vector.h.
|
inline |
Return a reference to the first object in the vector.
Definition at line 583 of file inplace_vector.h.
|
inline |
Return a constant reference to the first object in the vector.
Definition at line 593 of file inplace_vector.h.
|
inline |
Return a reference to the last object in the vector.
Definition at line 603 of file inplace_vector.h.
|
inline |
Return a constant reference to the last object in the vector.
Definition at line 613 of file inplace_vector.h.
|
inlinenoexcept |
Data access. Return a pointer to all objects in the vector.
Definition at line 631 of file inplace_vector.h.
|
inlinenoexcept |
Return a constant pointer to all objects in the vector.
Definition at line 642 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 662 of file inplace_vector.h.
|
inline |
Construct a new object at the end of the vector by copying value.
Definition at line 675 of file inplace_vector.h.
|
inline |
Construct a new object at the end of the vector by moving value.
Definition at line 688 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 699 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 714 of file inplace_vector.h.
|
inline |
Construct a new object at the end of the vector by copying value.
Definition at line 728 of file inplace_vector.h.
|
inline |
Construct a new object at the end of the vector by moving value.
Definition at line 742 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 755 of file inplace_vector.h.
|
inline |
Construct a new object at the location of position by copying value.
Definition at line 775 of file inplace_vector.h.
|
inline |
Construct a new object at the location of position by moving value.
Definition at line 784 of file inplace_vector.h.
|
inline |
Construct \(n\) new objects at the location of position by copying value.
Definition at line 793 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 806 of file inplace_vector.h.
|
inline |
Insert values from an initializer list at a position.
Definition at line 833 of file inplace_vector.h.
|
inline |
Erase a value.
Definition at line 842 of file inplace_vector.h.
|
inline |
Erase a range of values.
Definition at line 857 of file inplace_vector.h.
|
inlinenoexcept |
Swap the contents of this vector with another.
Definition at line 876 of file inplace_vector.h.
|
inlineconstexprnoexcept |
Clear the contents of the vector.
Definition at line 915 of file inplace_vector.h.
|
inlineconstexprprivatenoexcept |
Common function for resizing the vector.
Definition at line 981 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 1013 of file inplace_vector.h.
|
inlineconstexprprivatenoexcept |
Common function for creating or moving new values at the end of the vector.
Definition at line 1040 of file inplace_vector.h.
|
friend |
Friend swap function.
Definition at line 905 of file inplace_vector.h.
|
related |
Comparison operators. Equality operator for inplace_vector.
Definition at line 1103 of file inplace_vector.h.
|
related |
Inequality operator for inplace_vector.
Definition at line 1115 of file inplace_vector.h.
|
related |
Less than operator for inplace_vector.
Definition at line 1126 of file inplace_vector.h.
|
related |
Greater than operator for inplace_vector.
Definition at line 1139 of file inplace_vector.h.
|
related |
Less than or equal to operator for inplace_vector.
Definition at line 1150 of file inplace_vector.h.
|
related |
Greater than or equal to operator for inplace_vector.
Definition at line 1163 of file inplace_vector.h.
|
related |
Erase all values equal to value in vec.
Definition at line 1176 of file inplace_vector.h.
|
related |
Erase all values which satisfy the predicate pred in vec.
Definition at line 1192 of file inplace_vector.h.
| T std_cxx26::inplace_vector< T, N >::elements[N > 0 ? N :1] |
Definition at line 1074 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 1089 of file inplace_vector.h.