14#ifndef TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN
15#if TOML_GCC && TOML_GCC <= 7
16#define TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN 1
18#define TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN 0
22#if TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN && \
23 !defined(TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_ACKNOWLEDGED)
24#define TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_MESSAGE \
25 "If you're seeing this error it's because you're using one of toml++'s for_each() functions on " \
27 "known bugs in that area (e.g. GCC 7). On these compilers returning a bool (or " \
28 "bool-convertible) value from the " \
29 "for_each() callable causes spurious compilation failures, while returning nothing (void) " \
31 "If you believe this message is incorrect for your compiler, you can try your luck by " \
33 "TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN as 0 and recompiling - if it works, great! Let me know " \
35 "https://github.com/marzer/tomlplusplus/issues. Alternatively, if you don't have any need for " \
36 "early-exiting from " \
37 "for_each(), you can suppress this error by #defining " \
38 "TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_ACKNOWLEDGED " \
39 "and moving on with your life."
44 template <
bool IsConst>
48 friend class array_iterator;
50 using mutable_vector_iterator = std::vector<node_ptr>::iterator;
51 using const_vector_iterator = std::vector<node_ptr>::const_iterator;
52 using vector_iterator =
53 std::conditional_t<IsConst, const_vector_iterator, mutable_vector_iterator>;
55 mutable vector_iterator iter_;
58 using value_type = std::conditional_t<IsConst, const node, node>;
59 using reference = value_type&;
60 using pointer = value_type*;
61 using difference_type = ptrdiff_t;
62 using iterator_category =
typename std::iterator_traits<vector_iterator>::iterator_category;
65 array_iterator()
noexcept =
default;
68 explicit array_iterator(mutable_vector_iterator iter)
noexcept
73 explicit array_iterator(const_vector_iterator iter)
noexcept
78 array_iterator(
const array_iterator<false>& other)
noexcept
79 : iter_{other.iter_} {}
82 array_iterator(
const array_iterator&)
noexcept =
default;
84 array_iterator& operator=(
const array_iterator&)
noexcept =
default;
86 array_iterator& operator++()
noexcept
92 array_iterator operator++(
int)
noexcept
94 array_iterator
out{iter_};
99 array_iterator& operator--()
noexcept
105 array_iterator operator--(
int)
noexcept
107 array_iterator
out{iter_};
113 reference
operator*()
const noexcept {
return *iter_->get(); }
116 pointer operator->()
const noexcept {
return iter_->get(); }
119 explicit operator const vector_iterator&()
const noexcept {
return iter_; }
123 explicit operator const const_vector_iterator()
const noexcept {
return iter_; }
125 array_iterator& operator+=(ptrdiff_t
rhs)
noexcept {
130 array_iterator& operator-=(ptrdiff_t
rhs)
noexcept {
136 friend array_iterator
operator+(
const array_iterator&
lhs, ptrdiff_t
rhs)
noexcept {
137 return array_iterator{
lhs.iter_ +
rhs};
141 friend array_iterator
operator+(ptrdiff_t
lhs,
const array_iterator&
rhs)
noexcept {
142 return array_iterator{
rhs.iter_ +
lhs};
146 friend array_iterator
operator-(
const array_iterator&
lhs, ptrdiff_t
rhs)
noexcept {
147 return array_iterator{
lhs.iter_ -
rhs};
151 friend ptrdiff_t
operator-(
const array_iterator&
lhs,
const array_iterator&
rhs)
noexcept {
152 return lhs.iter_ -
rhs.iter_;
156 friend bool operator==(
const array_iterator&
lhs,
const array_iterator&
rhs)
noexcept {
157 return lhs.iter_ ==
rhs.iter_;
161 friend bool operator!=(
const array_iterator&
lhs,
const array_iterator&
rhs)
noexcept {
162 return lhs.iter_ !=
rhs.iter_;
166 friend bool operator<(
const array_iterator&
lhs,
const array_iterator&
rhs)
noexcept {
167 return lhs.iter_ <
rhs.iter_;
171 friend bool operator<=(
const array_iterator&
lhs,
const array_iterator&
rhs)
noexcept {
172 return lhs.iter_ <=
rhs.iter_;
176 friend bool operator>(
const array_iterator&
lhs,
const array_iterator&
rhs)
noexcept {
177 return lhs.iter_ >
rhs.iter_;
181 friend bool operator>=(
const array_iterator&
lhs,
const array_iterator&
rhs)
noexcept {
182 return lhs.iter_ >=
rhs.iter_;
186 reference operator[](ptrdiff_t idx)
const noexcept {
return *(iter_ + idx)->get(); }
189 struct array_init_elem {
190 mutable node_ptr
value;
192 template <
typename T>
262 using vector_type = std::vector<impl::node_ptr>;
263 using vector_iterator =
typename vector_type::iterator;
264 using const_vector_iterator =
typename vector_type::const_iterator;
269 array(
const impl::array_init_elem*,
const impl::array_init_elem*);
272 array(std::false_type, std::initializer_list<impl::array_init_elem> elems)
276 void preinsertion_resize(
size_t idx,
size_t count);
279 void insert_at_back(impl::node_ptr&&);
282 vector_iterator insert_at(const_vector_iterator, impl::node_ptr&&);
284 template <
typename T>
286 if constexpr (is_node_view<T>) {
289 insert_at_back(impl::make_node(
static_cast<T&&
>(
val),
flags));
294 size_t total_leaf_count()
const noexcept;
297 void flatten_child(
array&& child,
size_t& dest_index)
noexcept;
359 !
std::is_same_v<impl::remove_cvref<ElemType>,
array>),
360 typename ElemType, typename... ElemTypes)
362 explicit
array(ElemType&&
val, ElemTypes&&... vals)
363 :
array{std::false_type{},
364 std::initializer_list<impl::array_init_elem>{
static_cast<ElemType&&
>(
val),
365 static_cast<ElemTypes&&
>(vals)...}} {}
380 node_type
type() const noexcept final {
return node_type::array; }
392 bool is_homogeneous(node_type ntype,
const node*& first_nonmatch)
const noexcept final;
395 template <
typename ElemType =
void>
397 using type = impl::remove_cvref<impl::unwrap_node<ElemType>>;
398 static_assert(std::is_void_v<type> || toml::is_value<type> || toml::is_container<type>,
399 "The template type argument of array::is_homogeneous() must be void or one "
400 "of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
402 return is_homogeneous(impl::node_type_of<type>);
408 bool is_table() const noexcept final {
return false; }
412 bool is_array() const noexcept final {
return true; }
420 bool is_value() const noexcept final {
return false; }
444 bool is_date() const noexcept final {
return false; }
448 bool is_time() const noexcept final {
return false; }
469 toml::value<std::string>*
as_string() noexcept final {
return nullptr; }
473 toml::value<int64_t>*
as_integer() noexcept final {
return nullptr; }
481 toml::value<bool>*
as_boolean() noexcept final {
return nullptr; }
485 toml::value<date>*
as_date() noexcept final {
return nullptr; }
489 toml::value<time>*
as_time() noexcept final {
return nullptr; }
493 toml::value<date_time>*
as_date_time() noexcept final {
return nullptr; }
505 const toml::value<std::string>*
as_string() const noexcept final {
return nullptr; }
509 const toml::value<int64_t>*
as_integer() const noexcept final {
return nullptr; }
517 const toml::value<bool>*
as_boolean() const noexcept final {
return nullptr; }
521 const toml::value<date>*
as_date() const noexcept final {
return nullptr; }
525 const toml::value<time>*
as_time() const noexcept final {
return nullptr; }
529 const toml::value<date_time>*
as_date_time() const noexcept final {
return nullptr; }
559 return index < elems_.size() ? elems_[
index].get() :
nullptr;
587 template <
typename ElemType>
589 if (
auto val = get(
index))
return val->template as<ElemType>();
601 template <
typename ElemType>
603 return const_cast<array&
>(*this).template get_as<ElemType>(
index);
607 using node::operator[];
631 node&
front() noexcept {
return *elems_.front(); }
635 const node&
front() const noexcept {
return *elems_.front(); }
639 node&
back() noexcept {
return *elems_.back(); }
643 const node&
back() const noexcept {
return *elems_.back(); }
683 template <
typename T,
typename Array>
684 using for_each_elem_ref =
685 impl::copy_cvref<impl::wrap_node<impl::remove_cvref<impl::unwrap_node<T>>>, Array>;
687 template <
typename Func,
typename Array,
typename T>
689 std::disjunction<std::is_invocable<Func, for_each_elem_ref<T, Array>,
size_t>,
690 std::is_invocable<Func, size_t, for_each_elem_ref<T, Array>>,
691 std::is_invocable<Func, for_each_elem_ref<T, Array>>>;
693 template <
typename Func,
typename Array,
typename T>
694 using can_for_each_nothrow = std::conditional_t<
696 std::is_invocable_v<Func, for_each_elem_ref<T, Array>,
size_t>,
697 std::is_nothrow_invocable<Func, for_each_elem_ref<T, Array>,
size_t>,
700 std::is_invocable_v<Func, size_t, for_each_elem_ref<T, Array>>,
701 std::is_nothrow_invocable<Func, size_t, for_each_elem_ref<T, Array>>,
704 std::is_invocable_v<Func, for_each_elem_ref<T, Array>>,
705 std::is_nothrow_invocable<Func, for_each_elem_ref<T, Array>>, std::false_type>>>;
707 template <
typename Func,
typename Array>
708 using can_for_each_any =
709 std::disjunction<can_for_each<Func, Array, table>, can_for_each<Func, Array, array>,
710 can_for_each<Func, Array, std::string>, can_for_each<Func, Array, int64_t>,
711 can_for_each<Func, Array, double>, can_for_each<Func, Array, bool>,
712 can_for_each<Func, Array, date>, can_for_each<Func, Array, time>,
713 can_for_each<Func, Array, date_time>>;
715 template <
typename Func,
typename Array,
typename T>
716 using for_each_is_nothrow_one =
717 std::disjunction<std::negation<can_for_each<Func, Array, T>>,
718 can_for_each_nothrow<Func, Array, T>>;
720 template <
typename Func,
typename Array>
721 using for_each_is_nothrow = std::conjunction<
722 for_each_is_nothrow_one<Func, Array, table>, for_each_is_nothrow_one<Func, Array, array>,
723 for_each_is_nothrow_one<Func, Array, std::string>,
724 for_each_is_nothrow_one<Func, Array, int64_t>, for_each_is_nothrow_one<Func, Array, double>,
725 for_each_is_nothrow_one<Func, Array, bool>, for_each_is_nothrow_one<Func, Array, date>,
726 for_each_is_nothrow_one<Func, Array, time>,
727 for_each_is_nothrow_one<Func, Array, date_time>>;
729 template <
typename Func,
typename Array>
730 static void do_for_each(Func&& visitor, Array&& arr)
731 noexcept(for_each_is_nothrow<Func&&, Array&&>::value) {
733 can_for_each_any<Func&&, Array&&>::value,
734 "TOML array for_each visitors must be invocable for at least one of the toml::node "
735 "specializations:" TOML_SA_NODE_TYPE_LIST);
737 for (
size_t i = 0;
i < arr.size();
i++) {
738 using node_ref = impl::copy_cvref<toml::node, Array&&>;
739 static_assert(std::is_reference_v<node_ref>);
741#if TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN
743#ifndef TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_ACKNOWLEDGED
744 static_assert(impl::always_false<Func, Array, node_ref>,
745 TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_MESSAGE);
748 static_cast<node_ref
>(
static_cast<Array&&
>(arr)[
i])
749 .visit([&]([[maybe_unused]]
auto&& elem)
750 noexcept(for_each_is_nothrow_one<Func&&, Array&&,
decltype(elem)>
::value) {
751 using elem_ref = for_each_elem_ref<
decltype(elem), Array&&>;
752 static_assert(std::is_reference_v<elem_ref>);
755 if constexpr (std::is_invocable_v<Func&&, elem_ref, size_t>) {
756 static_cast<Func&&
>(visitor)(
static_cast<elem_ref
>(elem),
i);
760 else if constexpr (std::is_invocable_v<Func&&, size_t, elem_ref>) {
761 static_cast<Func&&
>(visitor)(
i,
static_cast<elem_ref
>(elem));
765 else if constexpr (std::is_invocable_v<Func&&, elem_ref>) {
766 static_cast<Func&&
>(visitor)(
static_cast<elem_ref
>(elem));
771 const auto keep_going =
772 static_cast<node_ref
>(
static_cast<Array&&
>(arr)[
i])
774 [&]([[maybe_unused]]
auto&& elem)
775 noexcept(for_each_is_nothrow_one<Func&&, Array&&,
decltype(elem)>
::value) {
776 using elem_ref = for_each_elem_ref<
decltype(elem), Array&&>;
777 static_assert(std::is_reference_v<elem_ref>);
780 if constexpr (std::is_invocable_v<Func&&, elem_ref, size_t>) {
782 decltype(
static_cast<Func&&
>(visitor)(
static_cast<elem_ref
>(elem),
i));
784 if constexpr (impl::is_constructible_or_convertible<bool, return_type>) {
785 return static_cast<bool>(
786 static_cast<Func&&
>(visitor)(
static_cast<elem_ref
>(elem),
i));
788 static_cast<Func&&
>(visitor)(
static_cast<elem_ref
>(elem),
i);
794 else if constexpr (std::is_invocable_v<Func&&, size_t, elem_ref>) {
796 decltype(
static_cast<Func&&
>(visitor)(
i,
static_cast<elem_ref
>(elem)));
798 if constexpr (impl::is_constructible_or_convertible<bool, return_type>) {
799 return static_cast<bool>(
800 static_cast<Func&&
>(visitor)(
i,
static_cast<elem_ref
>(elem)));
802 static_cast<Func&&
>(visitor)(
i,
static_cast<elem_ref
>(elem));
808 else if constexpr (std::is_invocable_v<Func&&, elem_ref>) {
810 decltype(
static_cast<Func&&
>(visitor)(
static_cast<elem_ref
>(elem)));
812 if constexpr (impl::is_constructible_or_convertible<bool, return_type>) {
813 return static_cast<bool>(
814 static_cast<Func&&
>(visitor)(
static_cast<elem_ref
>(elem)));
816 static_cast<Func&&
>(visitor)(
static_cast<elem_ref
>(elem));
826 if (!keep_going)
return;
894 template <
typename Func>
896 noexcept(for_each_is_nothrow<Func&&, array&>::value) {
897 do_for_each(
static_cast<Func&&
>(visitor), *
this);
902 template <
typename Func>
904 noexcept(for_each_is_nothrow<Func&&, array&&>::value) {
905 do_for_each(
static_cast<Func&&
>(visitor),
static_cast<array&&
>(*
this));
906 return static_cast<array&&
>(*this);
910 template <
typename Func>
912 noexcept(for_each_is_nothrow<Func&&, const array&>::value) {
913 do_for_each(
static_cast<Func&&
>(visitor), *
this);
918 template <
typename Func>
920 noexcept(for_each_is_nothrow<Func&&, const array&&>::value) {
921 do_for_each(
static_cast<Func&&
>(visitor),
static_cast<const array&&
>(*
this));
922 return static_cast<const array&&
>(*this);
932 bool empty() const noexcept {
return elems_.empty(); }
936 size_t size() const noexcept {
return elems_.size(); }
941 size_t max_size() const noexcept {
return elems_.max_size(); }
946 size_t capacity() const noexcept {
return elems_.capacity(); }
1010 template <
typename ElemType>
1011 void resize(
size_t new_size, ElemType&& default_init_val,
1014 !is_node_view<ElemType>,
1015 "The default element type argument to toml::array::resize may not be toml::node_view.");
1019 else if (new_size > elems_.size())
1020 insert(cend(), new_size - elems_.size(),
static_cast<ElemType&&
>(default_init_val),
1021 default_init_flags);
1121 array&
prune(
bool recursive =
true) &
noexcept;
1129 return static_cast<toml::array&&
>(this->prune(recursive));
1138 void clear() noexcept;
1172 template <typename ElemType>
1175 if constexpr (is_node_view<ElemType>) {
1178 return iterator{insert_at(const_vector_iterator{
pos},
1179 impl::make_node(
static_cast<ElemType&&
>(
val),
flags))};
1220 template <
typename ElemType>
1223 if constexpr (is_node_view<ElemType>) {
1228 return iterator{elems_.begin() + (const_vector_iterator{
pos} - elems_.cbegin())};
1230 return insert(
pos,
static_cast<ElemType&&
>(
val),
flags);
1232 const auto start_idx =
static_cast<size_t>(const_vector_iterator{
pos} - elems_.cbegin());
1233 preinsertion_resize(start_idx,
count);
1234 size_t i = start_idx;
1235 for (
size_t e = start_idx +
count - 1u;
i <
e;
i++)
1236 elems_[
i] = impl::make_node(
val,
flags);
1239 elems_[
i] = impl::make_node(
static_cast<ElemType&&
>(
val),
flags);
1240 return iterator{elems_.begin() +
static_cast<ptrdiff_t
>(start_idx)};
1259 template <
typename Iter>
1264 return iterator{elems_.begin() + (const_vector_iterator{
pos} - elems_.cbegin())};
1267 using deref_type =
decltype(*first);
1268 if constexpr (is_node_view<deref_type>) {
1269 for (
auto it = first; it !=
last; it++)
1270 if (!(*it))
count--;
1272 return iterator{elems_.begin() + (const_vector_iterator{
pos} - elems_.cbegin())};
1274 const auto start_idx =
static_cast<size_t>(const_vector_iterator{
pos} - elems_.cbegin());
1275 preinsertion_resize(start_idx,
static_cast<size_t>(
count));
1276 size_t i = start_idx;
1277 for (
auto it = first; it !=
last; it++) {
1278 if constexpr (is_node_view<deref_type>) {
1279 if (!(*it))
continue;
1281 if constexpr (std::is_rvalue_reference_v<deref_type>)
1282 elems_[
i++] = impl::make_node(std::move(*it),
flags);
1284 elems_[
i++] = impl::make_node(*it,
flags);
1286 return iterator{elems_.begin() +
static_cast<ptrdiff_t
>(start_idx)};
1304 template <
typename ElemType>
1307 return insert(
pos, ilist.begin(), ilist.end(),
flags);
1333 template <
typename ElemType = void,
typename... Args>
1335 using raw_elem_type = impl::remove_cvref<ElemType>;
1336 using elem_type = std::conditional_t<std::is_void_v<raw_elem_type>,
1337 impl::emplaced_type_of<Args&&...>, raw_elem_type>;
1339 using type = impl::remove_cvref<impl::unwrap_node<elem_type>>;
1340 static_assert(impl::is_native<type> || impl::is_one_of<type, table, array>,
1341 "Emplacement type parameter must be one of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
1344 insert_at(const_vector_iterator{
pos},
1345 impl::node_ptr{
new impl::wrap_node<type>{
static_cast<Args&&
>(args)...}})};
1376 template <
typename ElemType>
1381 if constexpr (is_node_view<ElemType>) {
1385 const auto it = elems_.begin() + (const_vector_iterator{
pos} - elems_.cbegin());
1386 *it = impl::make_node(
static_cast<ElemType&&
>(
val),
flags);
1411 template <
typename ElemType>
1413 emplace_back_if_not_empty_view(
static_cast<ElemType&&
>(
val),
flags);
1436 template <
typename ElemType = void,
typename... Args>
1438 using raw_elem_type = impl::remove_cvref<ElemType>;
1439 using elem_type = std::conditional_t<std::is_void_v<raw_elem_type>,
1440 impl::emplaced_type_of<Args&&...>, raw_elem_type>;
1442 static constexpr auto moving_node_ptr = std::is_same_v<elem_type, impl::node_ptr>
1443 &&
sizeof...(Args) == 1u
1444 && impl::first_is_same<impl::node_ptr&&, Args&&...>;
1446 using unwrapped_type = impl::remove_cvref<impl::unwrap_node<elem_type>>;
1448 static_assert(moving_node_ptr
1449 || impl::is_native<unwrapped_type>
1450 || impl::is_one_of<unwrapped_type, table, array>,
1451 "ElemType argument of array::emplace_back() must be one "
1452 "of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
1454 if constexpr (moving_node_ptr) {
1455 insert_at_back(
static_cast<Args&&
>(args)...);
1456 return *elems_.back();
1458 auto ptr =
new impl::wrap_node<unwrapped_type>{
static_cast<Args&&
>(args)...};
1459 insert_at_back(impl::node_ptr{
ptr});
1473 template <
typename T>
1475 using element_type = std::remove_const_t<typename T::value_type>;
1476 static_assert(impl::is_losslessly_convertible_to_native<element_type>,
1477 "Container element type must be losslessly convertible one of the native TOML "
1480 if (
lhs.size() !=
rhs.size())
return false;
1481 if (
rhs.size() == 0
u)
return true;
1484 for (
auto& list_elem :
rhs) {
1485 const auto elem =
lhs.get_as<impl::native_type_of<element_type>>(
i++);
1486 if (!elem || *elem != list_elem)
return false;
1517 template <
typename T>
1519 const std::initializer_list<T>&
rhs)
noexcept {
1520 return equal_to_container(
lhs,
rhs);
1523 template <typename T>);
1526 template <
typename T>
1528 return equal_to_container(
lhs,
rhs);
1534#if TOML_ENABLE_FORMATTERS
1540 impl::print_to_stream(
lhs,
rhs);
void count(T, T, const U &,...)
bool equal(const T &x, const U &y)
const minus< T > & operator-(const minus< T > &lhs, const minus< T > &rhs)
const plus_asgn< T > & operator*(const plus_asgn< T > &lhs, const plus_asgn< T > &rhs)
void operator+(typename A< T >::I, const A< T > &)
std::ostream_iterator< int, char, std::char_traits< char > > Iter
POXY_IMPLEMENTATION_DETAIL(impl::array_iterator< true >) 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_CONST_INLINE_GETTER table * as_table() noexcept final
Returns nullptr.
TOML_PURE_INLINE_GETTER node * get(size_t index) noexcept
Gets a pointer to the element at a specific index.
const node & const_reference
TOML_EXPORTED_MEMBER_FUNCTION void reserve(size_t new_capacity)
Reserves internal storage capacity up to a pre-determined number of elements.
TOML_NODISCARD friend bool operator==(const array &lhs, const std::initializer_list< T > &rhs) noexcept
Initializer list equality operator.
TOML_CONST_INLINE_GETTER bool is_boolean() const noexcept final
Returns false.
TOML_CONST_INLINE_GETTER bool is_array() const noexcept final
Returns true.
TOML_CONST_INLINE_GETTER bool is_date_time() const noexcept final
Returns false.
TOML_NODISCARD friend bool operator==(const array &lhs, const std::vector< T > &rhs) noexcept
Vector equality operator.
TOML_EXPORTED_MEMBER_FUNCTION array & operator=(array &&rhs) noexcept
Move-assignment operator.
TOML_CONST_INLINE_GETTER toml::value< double > * as_floating_point() noexcept final
Returns nullptr.
TOML_CONST_INLINE_GETTER const toml::value< bool > * as_boolean() const noexcept final
Returns nullptr.
TOML_NODISCARD iterator end() noexcept
Returns an iterator to one-past-the-last element.
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).
TOML_CONST_INLINE_GETTER bool is_string() const noexcept final
Returns false.
TOML_NODISCARD const_iterator cbegin() const noexcept
Returns an iterator to the first element.
TOML_CONST_INLINE_GETTER toml::value< std::string > * as_string() noexcept final
Returns nullptr.
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION bool is_homogeneous(node_type ntype, const node *&first_nonmatch) const noexcept final
TOML_NODISCARD node & back() noexcept
Returns a reference to the last element in the array.
array && prune(bool recursive=true) &&noexcept
Removes empty child arrays and tables (rvalue overload).
TOML_NODISCARD size_t capacity() const noexcept
Returns the current max number of elements that may be held in the array's internal storage.
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.
TOML_NODISCARD friend bool operator!=(const array &lhs, const array &rhs) noexcept
Inequality operator.
TOML_CONST_INLINE_GETTER bool is_floating_point() const noexcept final
Returns false.
TOML_CONST_INLINE_GETTER toml::value< bool > * as_boolean() noexcept final
Returns nullptr.
TOML_PURE_INLINE_GETTER const node * get(size_t index) const noexcept
Gets a pointer to the element at a specific index (const overload).
TOML_EXPORTED_MEMBER_FUNCTION iterator erase(const_iterator pos) noexcept
Removes the specified element from the array.
TOML_ASYMMETRICAL_EQUALITY_OPS(const array &, const std::vector< T > &, template< typename T >)
array && for_each(Func &&visitor) &&noexcept(for_each_is_nothrow< Func &&, array && >::value)
Invokes a visitor on each element in the array (rvalue overload).
decltype(auto) emplace_back(Args &&... args)
Emplaces a new element at the end of the array.
TOML_ASYMMETRICAL_EQUALITY_OPS(const array &, const std::initializer_list< T > &, template< typename T >)
TOML_NODISCARD const node & operator[](size_t index) const noexcept
Gets a reference to the element at a specific index.
TOML_NODISCARD const_iterator cend() const noexcept
Returns an iterator to one-past-the-last element.
TOML_EXPORTED_MEMBER_FUNCTION void pop_back() noexcept
Removes the last element from the array.
TOML_CONST_INLINE_GETTER const toml::value< time > * as_time() const noexcept final
Returns nullptr.
TOML_CONST_INLINE_GETTER bool is_time() const noexcept final
Returns false.
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_CONST_INLINE_GETTER const toml::value< date_time > * as_date_time() const noexcept final
Returns nullptr.
TOML_CONST_INLINE_GETTER bool is_integer() const noexcept final
Returns false.
TOML_EXPORTED_MEMBER_FUNCTION array & prune(bool recursive=true) &noexcept
Removes empty child arrays and tables.
array && flatten() &&
Flattens this array, recursively hoisting the contents of child arrays up into itself (rvalue overloa...
TOML_CONST_INLINE_GETTER toml::value< int64_t > * as_integer() noexcept final
Returns nullptr.
TOML_PURE_GETTER bool is_array_of_tables() const noexcept final
Returns true if the array contains only tables.
TOML_NODISCARD const_iterator begin() const noexcept
Returns an iterator to the first element.
TOML_NODISCARD const_iterator end() const noexcept
Returns an iterator to one-past-the-last element.
TOML_CONST_INLINE_GETTER const array * as_array() const noexcept final
Returns a const-qualified pointer to the array.
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.
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).
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 void truncate(size_t new_size)
Shrinks the array to the given size.
TOML_NODISCARD friend bool operator==(const array &lhs, const array &rhs) noexcept
Equality operator.
TOML_CONST_INLINE_GETTER toml::value< date_time > * as_date_time() noexcept final
Returns nullptr.
TOML_CONST_INLINE_GETTER node_type type() const noexcept final
Returns #toml::node_type::array.
TOML_CONST_INLINE_GETTER const table * as_table() const noexcept final
Returns nullptr.
array & for_each(Func &&visitor) &noexcept(for_each_is_nothrow< Func &&, array & >::value)
Invokes a visitor on each element in the array.
TOML_CONST_INLINE_GETTER bool is_value() const noexcept final
Returns false.
TOML_NODISCARD node & operator[](size_t index) noexcept
Gets a reference to the element at a specific index.
TOML_NODISCARD bool empty() const noexcept
Returns true if the array is empty.
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_CONST_INLINE_GETTER const toml::value< double > * as_floating_point() const noexcept final
Returns nullptr.
TOML_CONST_INLINE_GETTER const toml::value< int64_t > * as_integer() const noexcept final
Returns nullptr.
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION bool is_homogeneous(node_type ntype) const noexcept final
TOML_CONST_INLINE_GETTER const toml::value< std::string > * as_string() const noexcept final
Returns nullptr.
TOML_CONST_INLINE_GETTER toml::value< time > * as_time() noexcept final
Returns nullptr.
ptrdiff_t difference_type
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.
void resize(size_t new_size, ElemType &&default_init_val, value_flags default_init_flags=preserve_source_value_flags)
Resizes the array.
TOML_NODISCARD node & front() noexcept
Returns a reference to the first element in the array.
TOML_EXPORTED_MEMBER_FUNCTION array & flatten() &
Flattens this array, recursively hoisting the contents of child arrays up into itself.
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.
TOML_CONST_INLINE_GETTER const toml::value< date > * as_date() const noexcept final
Returns nullptr.
TOML_CONST_INLINE_GETTER toml::value< date > * as_date() noexcept final
Returns nullptr.
friend std::ostream & operator<<(std::ostream &lhs, const array &rhs)
Prints the array out to a stream as formatted TOML.
array_iterator iterator
A RandomAccessIterator for iterating over elements in a toml::array.
TOML_CONST_INLINE_GETTER bool is_number() const noexcept final
Returns false.
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION bool is_homogeneous(node_type ntype, node *&first_nonmatch) noexcept final
const_array_iterator const_iterator
A RandomAccessIterator for iterating over const elements in a toml::array.
iterator emplace(const_iterator pos, Args &&... args)
Emplaces a new element at a specific position in the array.
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.
TOML_CONST_INLINE_GETTER array * as_array() noexcept final
Returns a pointer to the array.
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.
TOML_EXPORTED_MEMBER_FUNCTION void shrink_to_fit()
Requests the removal of any unused internal storage capacity.
TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION array() noexcept
Default constructor.
TOML_NODISCARD const node & front() const noexcept
Returns a reference to the first element in the array.
TOML_NODISCARD const node & back() const noexcept
Returns a reference to the last element in the array.
TOML_NODISCARD size_t size() const noexcept
Returns the number of elements in the array.
TOML_CONST_INLINE_GETTER bool is_table() const noexcept final
Returns false.
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_CONST_INLINE_GETTER bool is_date() const noexcept final
Returns false.
void push_back(ElemType &&val, value_flags flags=preserve_source_value_flags)
Appends a new element to the end of the array.
enum TOML_OPEN_FLAGS_ENUM value_flags
Metadata associated with TOML values.
constexpr value_flags preserve_source_value_flags
Special #toml::value_flags constant used for array + table insert functions to specify that any value...
bool operator>(const DistancePair &lhs, const DistancePair &rhs)
#define TOML_CALLCONV
Calling convention to apply to exported free/static functions. \detail Not defined by default (let th...
#define TOML_EXPORTED_CLASS
An 'export' annotation to add to classes. \detail Not defined by default.
#define TOML_EXPORTED_STATIC_FUNCTION
An 'export' annotation to add to static class member functions. \detail Not defined by default.
#define TOML_ASSERT(expr)
Sets the assert function used by the library. \detail Defaults to the standard C assert().
#define TOML_EXPORTED_MEMBER_FUNCTION
An 'export' annotation to add to non-static class member functions. \detail Not defined by default.
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define TOML_NODISCARD_CTOR
#define POXY_IMPLEMENTATION_DETAIL(...)
#define TOML_CONSTRAINED_TEMPLATE(condition,...)
#define TOML_PURE_INLINE_GETTER
#define TOML_IMPL_NAMESPACE_END
#define TOML_IMPL_NAMESPACE_START
#define TOML_CONST_INLINE_GETTER