|
Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
|
#include <array.hpp>


Public Types | |
| using | value_type = node |
| using | size_type = size_t |
| using | difference_type = ptrdiff_t |
| using | reference = node & |
| using | const_reference = const node & |
Public Member Functions | |
| TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION | array () noexcept |
| Default constructor. | |
| TOML_EXPORTED_MEMBER_FUNCTION | ~array () noexcept |
| TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION | array (const array &) |
| Copy constructor. | |
| TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION | array (array &&other) noexcept |
| Move constructor. | |
| TOML_CONSTRAINED_TEMPLATE ((sizeof...(ElemTypes) > 0||!std::is_same_v< impl::remove_cvref< ElemType >, array >), typename ElemType, typename... ElemTypes) TOML_NODISCARD_CTOR explicit array(ElemType &&val | |
| Constructs an array with one or more initial elements. | |
| TOML_EXPORTED_MEMBER_FUNCTION array & | operator= (array &&rhs) noexcept |
| Move-assignment operator. | |
Type checks | |
| TOML_CONST_INLINE_GETTER node_type | type () const noexcept final |
| Returns #toml::node_type::array. | |
| TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION bool | is_homogeneous (node_type ntype) const noexcept final |
| TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION bool | is_homogeneous (node_type ntype, node *&first_nonmatch) noexcept final |
| TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION bool | is_homogeneous (node_type ntype, const node *&first_nonmatch) const noexcept final |
| TOML_CONST_INLINE_GETTER bool | is_table () const noexcept final |
Returns false. | |
| TOML_CONST_INLINE_GETTER bool | is_array () const noexcept final |
Returns true. | |
| TOML_PURE_GETTER bool | is_array_of_tables () const noexcept final |
Returns true if the array contains only tables. | |
| TOML_CONST_INLINE_GETTER bool | is_value () const noexcept final |
Returns false. | |
| TOML_CONST_INLINE_GETTER bool | is_string () const noexcept final |
Returns false. | |
| TOML_CONST_INLINE_GETTER bool | is_integer () const noexcept final |
Returns false. | |
| TOML_CONST_INLINE_GETTER bool | is_floating_point () const noexcept final |
Returns false. | |
| TOML_CONST_INLINE_GETTER bool | is_number () const noexcept final |
Returns false. | |
| TOML_CONST_INLINE_GETTER bool | is_boolean () const noexcept final |
Returns false. | |
| TOML_CONST_INLINE_GETTER bool | is_date () const noexcept final |
Returns false. | |
| TOML_CONST_INLINE_GETTER bool | is_time () const noexcept final |
Returns false. | |
| TOML_CONST_INLINE_GETTER bool | is_date_time () const noexcept final |
Returns false. | |
Type casts | |
| TOML_CONST_INLINE_GETTER table * | as_table () noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER array * | as_array () noexcept final |
| Returns a pointer to the array. | |
| TOML_CONST_INLINE_GETTER toml::value< std::string > * | as_string () noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER toml::value< int64_t > * | as_integer () noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER toml::value< double > * | as_floating_point () noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER toml::value< bool > * | as_boolean () noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER toml::value< date > * | as_date () noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER toml::value< time > * | as_time () noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER toml::value< date_time > * | as_date_time () noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER const table * | as_table () const noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER const array * | as_array () const noexcept final |
| Returns a const-qualified pointer to the array. | |
| TOML_CONST_INLINE_GETTER const toml::value< std::string > * | as_string () const noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER const toml::value< int64_t > * | as_integer () const noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER const toml::value< double > * | as_floating_point () const noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER const toml::value< bool > * | as_boolean () const noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER const toml::value< date > * | as_date () const noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER const toml::value< time > * | as_time () const noexcept final |
Returns nullptr. | |
| TOML_CONST_INLINE_GETTER const toml::value< date_time > * | as_date_time () const noexcept final |
Returns nullptr. | |
Value retrieval | |
| TOML_PURE_INLINE_GETTER node * | get (size_t index) noexcept |
| Gets a pointer to the element at a specific index. | |
| TOML_PURE_INLINE_GETTER const node * | get (size_t index) const noexcept |
| Gets a pointer to the element at a specific index (const overload). | |
| template<typename ElemType > | |
| TOML_NODISCARD impl::wrap_node< ElemType > * | get_as (size_t index) noexcept |
| Gets a pointer to the element at a specific index if it is a particular type. | |
| template<typename ElemType > | |
| TOML_NODISCARD const impl::wrap_node< ElemType > * | get_as (size_t index) const noexcept |
| Gets a pointer to the element at a specific index if it is a particular type (const overload). | |
| TOML_NODISCARD node & | operator[] (size_t index) noexcept |
| Gets a reference to the element at a specific index. | |
| TOML_NODISCARD const node & | operator[] (size_t index) const noexcept |
| Gets a reference to the element at a specific index. | |
| TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION node & | at (size_t index) |
Gets a reference to the element at a specific index, throwing std::out_of_range if none existed. | |
| TOML_NODISCARD const node & | at (size_t index) const |
Gets a reference to the element at a specific index, throwing std::out_of_range if none existed. | |
| TOML_NODISCARD node & | front () noexcept |
| Returns a reference to the first element in the array. | |
| TOML_NODISCARD const node & | front () const noexcept |
| Returns a reference to the first element in the array. | |
| TOML_NODISCARD node & | back () noexcept |
| Returns a reference to the last element in the array. | |
| TOML_NODISCARD const node & | back () const noexcept |
| Returns a reference to the last element in the array. | |
Size and Capacity | |
| TOML_NODISCARD bool | empty () const noexcept |
| Returns true if the array is empty. | |
| TOML_NODISCARD size_t | size () const noexcept |
| Returns the number of elements in the array. | |
| TOML_NODISCARD size_t | max_size () const noexcept |
| Returns the maximum number of elements that can be stored in an array on the current platform. | |
| TOML_NODISCARD size_t | capacity () const noexcept |
| Returns the current max number of elements that may be held in the array's internal storage. | |
| TOML_EXPORTED_MEMBER_FUNCTION void | reserve (size_t new_capacity) |
| Reserves internal storage capacity up to a pre-determined number of elements. | |
| TOML_EXPORTED_MEMBER_FUNCTION void | shrink_to_fit () |
| Requests the removal of any unused internal storage capacity. | |
| TOML_EXPORTED_MEMBER_FUNCTION void | truncate (size_t new_size) |
| Shrinks the array to the given size. | |
| template<typename ElemType > | |
| void | resize (size_t new_size, ElemType &&default_init_val, value_flags default_init_flags=preserve_source_value_flags) |
| Resizes the array. | |
Erasure | |
| TOML_EXPORTED_MEMBER_FUNCTION iterator | erase (const_iterator pos) noexcept |
| Removes the specified element from the array. | |
| TOML_EXPORTED_MEMBER_FUNCTION iterator | erase (const_iterator first, const_iterator last) noexcept |
| Removes the elements in the range [first, last) from the array. | |
| TOML_EXPORTED_MEMBER_FUNCTION array & | flatten () & |
| Flattens this array, recursively hoisting the contents of child arrays up into itself. | |
| array && | flatten () && |
| Flattens this array, recursively hoisting the contents of child arrays up into itself (rvalue overload). | |
| TOML_EXPORTED_MEMBER_FUNCTION array & | prune (bool recursive=true) &noexcept |
| Removes empty child arrays and tables. | |
| array && | prune (bool recursive=true) &&noexcept |
| Removes empty child arrays and tables (rvalue overload). | |
| TOML_EXPORTED_MEMBER_FUNCTION void | pop_back () noexcept |
| Removes the last element from the array. | |
| TOML_EXPORTED_MEMBER_FUNCTION void | clear () noexcept |
| Removes all elements from the array. | |
Insertion and Emplacement | |
| template<typename ElemType > | |
| iterator | insert (const_iterator pos, ElemType &&val, value_flags flags=preserve_source_value_flags) |
| Inserts a new element at a specific position in the array. | |
| template<typename ElemType > | |
| iterator | insert (const_iterator pos, size_t count, ElemType &&val, value_flags flags=preserve_source_value_flags) |
| Repeatedly inserts a new element starting at a specific position in the array. | |
| template<typename Iter > | |
| iterator | insert (const_iterator pos, Iter first, Iter last, value_flags flags=preserve_source_value_flags) |
| Inserts a range of elements into the array at a specific position. | |
| template<typename ElemType > | |
| iterator | insert (const_iterator pos, std::initializer_list< ElemType > ilist, value_flags flags=preserve_source_value_flags) |
| Inserts a range of elements into the array at a specific position. | |
| template<typename ElemType = void, typename... Args> | |
| iterator | emplace (const_iterator pos, Args &&... args) |
| Emplaces a new element at a specific position in the array. | |
| template<typename ElemType > | |
| iterator | replace (const_iterator pos, ElemType &&val, value_flags flags=preserve_source_value_flags) |
| Replaces the element at a specific position in the array with a different value. | |
| template<typename ElemType > | |
| void | push_back (ElemType &&val, value_flags flags=preserve_source_value_flags) |
| Appends a new element to the end of the array. | |
| template<typename ElemType = void, typename... Args> | |
| decltype(auto) | emplace_back (Args &&... args) |
| Emplaces a new element at the end of the array. | |
Data Fields | |
| ElemTypes && | vals: array{std::false_type{} |
Friends | |
| std::ostream & | operator<< (std::ostream &lhs, const array &rhs) |
| Prints the array out to a stream as formatted TOML. | |
Iteration | |
| using | iterator = array_iterator |
| A RandomAccessIterator for iterating over elements in a toml::array. | |
| using | const_iterator = const_array_iterator |
| A RandomAccessIterator for iterating over const elements in a toml::array. | |
| TOML_NODISCARD iterator | begin () noexcept |
| Returns an iterator to the first element. | |
| TOML_NODISCARD const_iterator | begin () const noexcept |
| Returns an iterator to the first element. | |
| TOML_NODISCARD const_iterator | cbegin () const noexcept |
| Returns an iterator to the first element. | |
| TOML_NODISCARD iterator | end () noexcept |
| Returns an iterator to one-past-the-last element. | |
| TOML_NODISCARD const_iterator | end () const noexcept |
| Returns an iterator to one-past-the-last element. | |
| TOML_NODISCARD const_iterator | cend () const noexcept |
| Returns an iterator to one-past-the-last element. | |
| template<typename Func > | |
| array & | for_each (Func &&visitor) &noexcept(for_each_is_nothrow< Func &&, array & >::value) |
| Invokes a visitor on each element in the array. | |
| template<typename Func > | |
| array && | for_each (Func &&visitor) &&noexcept(for_each_is_nothrow< Func &&, array && >::value) |
| Invokes a visitor on each element in the array (rvalue overload). | |
| template<typename Func > | |
| const array & | for_each (Func &&visitor) const &noexcept(for_each_is_nothrow< Func &&, const array & >::value) |
| Invokes a visitor on each element in the array (const lvalue overload). | |
| template<typename Func > | |
| const array && | for_each (Func &&visitor) const &&noexcept(for_each_is_nothrow< Func &&, const array && >::value) |
| Invokes a visitor on each element in the array (const rvalue overload). | |
Equality | |
| TOML_ASYMMETRICAL_EQUALITY_OPS (const array &, const std::initializer_list< T > &, template< typename T >) | |
| TOML_ASYMMETRICAL_EQUALITY_OPS (const array &, const std::vector< T > &, template< typename T >) | |
| TOML_NODISCARD friend bool | operator== (const array &lhs, const array &rhs) noexcept |
| Equality operator. | |
| TOML_NODISCARD friend bool | operator!= (const array &lhs, const array &rhs) noexcept |
| Inequality operator. | |
| template<typename T > | |
| TOML_NODISCARD friend bool | operator== (const array &lhs, const std::initializer_list< T > &rhs) noexcept |
| Initializer list equality operator. | |
| template<typename T > | |
| TOML_NODISCARD friend bool | operator== (const array &lhs, const std::vector< T > &rhs) noexcept |
| Vector equality operator. | |
A TOML array.
\detail The interface of this type is modeled after std::vector, with some additional considerations made for the heterogeneous nature of a TOML array.
\godbolt{sjK4da}
\cpp
toml::table tbl = toml::parse(R"( arr = [1, 2, 3, 4, 'five'] )"sv);
// get the element as an array toml::array& arr = *tbl.get_as<toml::array>("arr"); std::cout << arr << "\n";
// increment each element with visit() for (auto&& elem : arr) { elem.visit([](auto&& el) noexcept { if constexpr (toml::is_number<decltype(el)>) (*el)++; else if constexpr (toml::is_string<decltype(el)>) el = "six"sv; }); } std::cout << arr << "\n";
// add and remove elements arr.push_back(7); arr.push_back(8.0f); arr.push_back("nine"sv); arr.erase(arr.cbegin()); std::cout << arr << "\n";
// emplace elements arr.emplace_back("ten"); arr.emplace_back<toml::array>(11, 12.0); std::cout << arr << "\n"; \ecpp
\out [ 1, 2, 3, 4, 'five' ] [ 2, 3, 4, 5, 'six' ] [ 3, 4, 5, 'six', 7, 8.0, 'nine' ] [ 3, 4, 5, 'six', 7, 8.0, 'nine', 'ten', [ 11, 12.0 ] ] \eout
| using array::const_iterator = const_array_iterator |
| using array::iterator = array_iterator |
|
noexcept |
Default constructor.
|
noexcept |
| TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION array::array | ( | const array & | ) |
Copy constructor.
|
noexcept |
Move constructor.
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
| TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION node & array::at | ( | size_t | index | ) |
Gets a reference to the element at a specific index, throwing std::out_of_range if none existed.
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
Removes all elements from the array.
|
inline |
Emplaces a new element at a specific position in the array.
\detail \cpp auto arr = toml::array{ 1, 2 };
//add a string using std::string's substring constructor arr.emplace<std::string>(arr.cbegin() + 1, "this is not a drill"sv, 14, 5); std::cout << arr << "\n"; \ecpp
\out [ 1, 'drill', 2 ] \eout
| ElemType | toml::table, toml::array, or any native TOML value type. |
| Args | Value constructor argument types. |
| pos | The insertion position. |
| args | Arguments to forward to the value's constructor. |
|
inline |
Emplaces a new element at the end of the array.
\detail \cpp auto arr = toml::array{ 1, 2 }; arr.emplace_back<toml::array>(3, "four"sv); std::cout << arr << "\n"; \ecpp
\out [ 1, 2, [ 3, 'four' ] ] \eout
| ElemType | toml::table, toml::array, or a native TOML value type |
| Args | Element constructor argument types. |
| args | Arguments to forward to the elements's constructor. |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
Removes the elements in the range [first, last) from the array.
\detail \cpp auto arr = toml::array{ 1, "bad", "karma" 2 }; std::cout << arr << "\n";
arr.erase(arr.cbegin() + 1, arr.cbegin() + 3); std::cout << arr << "\n"; \ecpp
\out [ 1, 'bad', 'karma', 3 ] [ 1, 3 ] \eout
| first | Iterator to the first element being erased. |
| last | Iterator to the one-past-the-last element being erased. |
|
noexcept |
Removes the specified element from the array.
\detail \cpp auto arr = toml::array{ 1, 2, 3 }; std::cout << arr << "\n";
arr.erase(arr.cbegin() + 1); std::cout << arr << "\n"; \ecpp
\out [ 1, 2, 3 ] [ 1, 3 ] \eout
| pos | Iterator to the element being erased. |
| TOML_EXPORTED_MEMBER_FUNCTION array & array::flatten | ( | ) | & |
Flattens this array, recursively hoisting the contents of child arrays up into itself.
\detail \cpp
auto arr = toml::array{ 1, 2, toml::array{ 3, 4, toml::array{ 5 } }, 6, toml::array{} }; std::cout << arr << "\n";
arr.flatten(); std::cout << arr << "\n"; \ecpp
\out [ 1, 2, [ 3, 4, [ 5 ] ], 6, [] ] [ 1, 2, 3, 4, 5, 6 ] \eout
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
Invokes a visitor on each element in the array.
| Func | A callable type invocable with one of the following signatures:
Where:
bool (or something convertible to bool) will cause iteration to stop if they return false. |
| visitor | The visitor object. |
\cpp toml::array arr{ 0, 1, 2, 3.0, "four", "five", 6 };
// select only the integers using a strongly-typed visitor arr.for_each([](toml::value<int64_t>& elem) { std::cout << elem << ", "; }); std::cout << "\n";
// select all the numeric values using a generic visitor + is_number<> metafunction arr.for_each([](auto&& elem) { if constexpr (toml::is_number<decltype(elem)>) std::cout << elem << ", "; }); std::cout << "\n";
// select all the numeric values until we encounter something non-numeric arr.for_each([](auto&& elem) { if constexpr (toml::is_number<decltype(elem)>) { std::cout << elem << ", "; return true; // "keep going" } else return false; // "stop!"
}); std::cout << "\n";
\ecpp \out 0, 1, 2, 6, 0, 1, 2, 3.0, 6, 0, 1, 2, 3.0, \eout
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Gets a pointer to the element at a specific index.
\detail \cpp auto arr = toml::array{ 99, "bottles of beer on the wall" }; std::cout << "element [0] exists: "sv << !!arr.get(0) << "\n"; std::cout << "element [1] exists: "sv << !!arr.get(1) << "\n"; std::cout << "element [2] exists: "sv << !!arr.get(2) << "\n"; if (toml::node* val = arr.get(0)) std::cout << "element [0] is an "sv << val->type() << "\n"; \ecpp
\out element [0] exists: true element [1] exists: true element [2] exists: false element [0] is an integer \eout
| index | The element's index. |
|
inlinenoexcept |
Gets a pointer to the element at a specific index if it is a particular type (const overload).
| ElemType | toml::table, toml::array, or a native TOML value type |
| index | The element's index. |
|
inlinenoexcept |
Gets a pointer to the element at a specific index if it is a particular type.
\detail \cpp auto arr = toml::array{ 42, "is the meaning of life, apparently."sv }; if (toml::value<int64_t>* val = arr.get_as<int64_t>(0)) std::cout << "element [0] is an integer with value "sv << *val << "\n"; \ecpp
\out element [0] is an integer with value 42 \eout
| ElemType | toml::table, toml::array, or a native TOML value type |
| index | The element's index. |
|
inline |
Inserts a new element at a specific position in the array.
\detail \cpp auto arr = toml::array{ 1, 3 }; arr.insert(arr.cbegin() + 1, "two"); arr.insert(arr.cend(), toml::array{ 4, 5 }); std::cout << arr << "\n"; \ecpp
\out [ 1, 'two', 3, [ 4, 5 ] ] \eout
| ElemType | toml::node, toml::node_view, toml::table, toml::array, or a native TOML value type (or a type promotable to one). |
| pos | The insertion position. |
| val | The node or value being inserted. |
| flags | Value flags to apply to new values. |
end() if the input value was a null toml::node_view, because no insertion can take place. This is the only circumstance in which this can occur.
|
inline |
Inserts a range of elements into the array at a specific position.
| Iter | An iterator type. Must satisfy ForwardIterator. |
| pos | The insertion position. |
| first | Iterator to the first node or value being inserted. |
| last | Iterator to the one-past-the-last node or value being inserted. |
| flags | Value flags to apply to new values. |
|
inline |
Repeatedly inserts a new element starting at a specific position in the array.
\detail \cpp auto arr = toml::array{ "with an evil twinkle in its eye the goose said", "and immediately we knew peace was never an option." }; arr.insert(arr.cbegin() + 1, 3, "honk"); std::cout << arr << "\n"; \ecpp
\out [ 'with an evil twinkle in its eye the goose said', 'honk', 'honk', 'honk', 'and immediately we knew peace was never an option.' ] \eout
| ElemType | toml::node, toml::node_view, toml::table, toml::array, or a native TOML value type (or a type promotable to one). |
| pos | The insertion position. |
| count | The number of times the node or value should be inserted. |
| val | The node or value being inserted. |
| flags | Value flags to apply to new values. |
end() if the input value was a null toml::node_view, because no insertion can take place. This is the only circumstance in which this can occur.
|
inline |
Inserts a range of elements into the array at a specific position.
| ElemType | toml::node_view, toml::table, toml::array, or a native TOML value type (or a type promotable to one). |
| pos | The insertion position. |
| ilist | An initializer list containing the values to be inserted. |
| flags | Value flags to apply to new values. |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
finalnoexcept |
|
finalnoexcept |
|
finalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinefinalnoexcept |
|
inlinenoexcept |
|
noexcept |
Move-assignment operator.
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
Removes the last element from the array.
|
noexcept |
Removes empty child arrays and tables.
\detail \cpp
auto arr = toml::array{ 1, 2, toml::array{ }, toml::array{ 3, toml::array{ } }, 4 }; std::cout << arr << "\n";
arr.prune(true); std::cout << arr << "\n"; \ecpp
\out [ 1, 2, [], [ 3, [] ], 4 ] [ 1, 2, [ 3 ], 4 ] \eout
| recursive | Should child arrays and tables themselves be pruned? |
|
inline |
Appends a new element to the end of the array.
\detail \cpp auto arr = toml::array{ 1, 2 }; arr.push_back(3); arr.push_back(4.0); arr.push_back(toml::array{ 5, "six"sv }); std::cout << arr << "\n"; \ecpp
\out [ 1, 2, 3, 4.0, [ 5, 'six' ] ] \eout
| ElemType | toml::node, toml::node_view, toml::table, toml::array, or a native TOML value type |
| val | The node or value being added. |
| flags | Value flags to apply to new values. |
|
inline |
Replaces the element at a specific position in the array with a different value.
\detail \cpp auto arr = toml::array{ 1, 2, 3 }; std::cout << arr << "\n"; arr.replace(arr.cbegin() + 1, "two"); std::cout << arr << "\n"; \ecpp
\out [ 1, 2, 3 ] [ 1, 'two', 3 ] \eout
| ElemType | toml::node, toml::node_view, toml::table, toml::array, or a native TOML value type (or a type promotable to one). |
| pos | The insertion position. |
| val | The node or value being inserted. |
| flags | Value flags to apply to new values. |
end() if the input value was a null toml::node_view, because no replacement can take place. This is the only circumstance in which this can occur. | TOML_EXPORTED_MEMBER_FUNCTION void array::reserve | ( | size_t | new_capacity | ) |
Reserves internal storage capacity up to a pre-determined number of elements.
|
inline |
Resizes the array.
\detail \godbolt{W5zqx3}
\cpp auto arr = toml::array{ 1, 2, 3 }; std::cout << arr << "\n";
arr.resize(6, 42); std::cout << arr << "\n";
arr.resize(2, 0); std::cout << arr << "\n"; \ecpp
\out [ 1, 2, 3 ] [ 1, 2, 3, 42, 42, 42 ] [ 1, 2 ] \eout
| ElemType | toml::node, toml::table, toml::array, or a native TOML value type (or a type promotable to one). |
| new_size | The number of elements the array will have after resizing. |
| default_init_val | The node or value used to initialize new elements if the array needs to grow. |
| default_init_flags | Value flags to apply to new values created if new elements are created by growing. |
| TOML_EXPORTED_MEMBER_FUNCTION void array::shrink_to_fit | ( | ) |
Requests the removal of any unused internal storage capacity.
|
inlinenoexcept |
| array::TOML_ASYMMETRICAL_EQUALITY_OPS | ( | const array & | , |
| const std::initializer_list< T > & | , | ||
| template< typename T > | |||
| ) |
| array::TOML_ASYMMETRICAL_EQUALITY_OPS | ( | const array & | , |
| const std::vector< T > & | , | ||
| template< typename T > | |||
| ) |
| array::TOML_CONSTRAINED_TEMPLATE | ( | (sizeof...(ElemTypes) > 0|| !std::is_same_v< impl::remove_cvref< ElemType >, array >) | , |
| typename ElemType | , | ||
| typename... | ElemTypes | ||
| ) | && |
Constructs an array with one or more initial elements.
\detail \cpp auto arr = toml::array{ 1, 2.0, "three"sv, toml::array{ 4, 5 } }; std::cout << arr << "\n"; \ecpp
\out [ 1, 2.0, 'three', [ 4, 5 ] ] \eout
If you need to construct an array with one child array element, the array's move constructor will take precedence and perform a move-construction instead. You can use toml::inserter to suppress this behaviour: \cpp // desired result: [ [ 42 ] ] auto bad = toml::array{ toml::array{ 42 } } auto good = toml::array{ toml::inserter{ toml::array{ 42 } } } std::cout << "bad: " << bad << "\n"; std::cout << "good:" << good << "\n"; \ecpp
\out bad: [ 42 ] good: [ [ 42 ] ] \eout
| ElemType | One of the TOML node or value types (or a type promotable to one). |
| ElemTypes | One of the TOML node or value types (or a type promotable to one). |
| val | The node or value used to initialize element 0. |
| vals | The nodes or values used to initialize elements 1...N. |
| TOML_EXPORTED_MEMBER_FUNCTION void array::truncate | ( | size_t | new_size | ) |
Shrinks the array to the given size.
\detail \godbolt{rxEzK5}
\cpp auto arr = toml::array{ 1, 2, 3 }; std::cout << arr << "\n";
arr.truncate(5); // no-op std::cout << arr << "\n";
arr.truncate(1); std::cout << arr << "\n"; \ecpp
\out [ 1, 2, 3 ] [ 1, 2, 3 ] [ 1] \eout
|
inlinefinalnoexcept |
|
friend |
|
friend |
Prints the array out to a stream as formatted TOML.
\availability This operator is only available when TOML_ENABLE_FORMATTERS is enabled.
|
friend |
|
friend |
|
friend |