diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index ad1130c..98b12fc 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -9,7 +9,7 @@ assignees: marzer
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index 6c98ee1..76688cd 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -9,7 +9,7 @@ assignees: marzer
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a9542ee..9317845 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -3,8 +3,10 @@ Contributions are very welcome! Either by [reporting issues] or submitting pull
If you wish to submit a PR, please be aware that:
- The single-header file `toml.hpp` is generated by a script; make your changes in the files in
`include`, **not** in `toml.hpp`.
-- Your changes should compile warning-free on at least one of gcc 8.3.0, clang 8.0, and MSVC 19.2X
- (Visual Studio 2019). All three is a bonus.
+- Your changes should compile warning-free on at least one of:
+ - GCC 8 or higher
+ - Clang 8 or higher
+ - MSVC 19.2X (Visual Studio 2019) or higher
- You should regenerate the single-header file as part of your PR (a CI check will fail if you don't).
diff --git a/include/toml++/impl/array.h b/include/toml++/impl/array.h
index 141aabb..d9311be 100644
--- a/include/toml++/impl/array.h
+++ b/include/toml++/impl/array.h
@@ -249,7 +249,7 @@ TOML_NAMESPACE_START
/// \cond
friend class TOML_PARSER_TYPENAME;
- std::vector> elements;
+ std::vector> elems_;
TOML_API
void preinsertion_resize(size_t idx, size_t count);
@@ -262,7 +262,7 @@ TOML_NAMESPACE_START
if (!val)
return;
}
- elements.emplace_back(impl::make_node(static_cast(val), flags));
+ elems_.emplace_back(impl::make_node(static_cast(val), flags));
}
TOML_NODISCARD
@@ -363,11 +363,11 @@ TOML_NAMESPACE_START
TOML_NODISCARD_CTOR
explicit array(ElemType&& val, ElemTypes&&... vals)
{
- elements.reserve(sizeof...(ElemTypes) + 1u);
- emplace_back_if_not_empty_view(static_cast(val), value_flags::none);
+ elems_.reserve(sizeof...(ElemTypes) + 1u);
+ emplace_back_if_not_empty_view(static_cast(val), preserve_source_value_flags);
if constexpr (sizeof...(ElemTypes) > 0)
{
- (emplace_back_if_not_empty_view(static_cast(vals), value_flags::none), ...);
+ (emplace_back_if_not_empty_view(static_cast(vals), preserve_source_value_flags), ...);
}
#if TOML_LIFETIME_HOOKS
@@ -442,130 +442,130 @@ TOML_NAMESPACE_START
TOML_NODISCARD
node& operator[](size_t index) noexcept
{
- return *elements[index];
+ return *elems_[index];
}
/// \brief Gets a reference to the element at a specific index.
TOML_NODISCARD
const node& operator[](size_t index) const noexcept
{
- return *elements[index];
+ return *elems_[index];
}
/// \brief Returns a reference to the first element in the array.
TOML_NODISCARD
node& front() noexcept
{
- return *elements.front();
+ return *elems_.front();
}
/// \brief Returns a reference to the first element in the array.
TOML_NODISCARD
const node& front() const noexcept
{
- return *elements.front();
+ return *elems_.front();
}
/// \brief Returns a reference to the last element in the array.
TOML_NODISCARD
node& back() noexcept
{
- return *elements.back();
+ return *elems_.back();
}
/// \brief Returns a reference to the last element in the array.
TOML_NODISCARD
const node& back() const noexcept
{
- return *elements.back();
+ return *elems_.back();
}
/// \brief Returns an iterator to the first element.
TOML_NODISCARD
iterator begin() noexcept
{
- return { elements.begin() };
+ return { elems_.begin() };
}
/// \brief Returns an iterator to the first element.
TOML_NODISCARD
const_iterator begin() const noexcept
{
- return { elements.cbegin() };
+ return { elems_.cbegin() };
}
/// \brief Returns an iterator to the first element.
TOML_NODISCARD
const_iterator cbegin() const noexcept
{
- return { elements.cbegin() };
+ return { elems_.cbegin() };
}
/// \brief Returns an iterator to one-past-the-last element.
TOML_NODISCARD
iterator end() noexcept
{
- return { elements.end() };
+ return { elems_.end() };
}
/// \brief Returns an iterator to one-past-the-last element.
TOML_NODISCARD
const_iterator end() const noexcept
{
- return { elements.cend() };
+ return { elems_.cend() };
}
/// \brief Returns an iterator to one-past-the-last element.
TOML_NODISCARD
const_iterator cend() const noexcept
{
- return { elements.cend() };
+ return { elems_.cend() };
}
/// \brief Returns true if the array is empty.
TOML_NODISCARD
bool empty() const noexcept
{
- return elements.empty();
+ return elems_.empty();
}
/// \brief Returns the number of elements in the array.
TOML_NODISCARD
size_t size() const noexcept
{
- return elements.size();
+ return elems_.size();
}
/// \brief Reserves internal storage capacity up to a pre-determined number of elements.
void reserve(size_t new_capacity)
{
- elements.reserve(new_capacity);
+ elems_.reserve(new_capacity);
}
/// \brief Removes all elements from the array.
void clear() noexcept
{
- elements.clear();
+ elems_.clear();
}
/// \brief Returns the maximum number of elements that can be stored in an array on the current platform.
TOML_NODISCARD
size_t max_size() const noexcept
{
- return elements.max_size();
+ return elems_.max_size();
}
/// \brief Returns the current max number of elements that may be held in the array's internal storage.
TOML_NODISCARD
size_t capacity() const noexcept
{
- return elements.capacity();
+ return elems_.capacity();
}
/// \brief Requests the removal of any unused internal storage capacity.
void shrink_to_fit()
{
- elements.shrink_to_fit();
+ elems_.shrink_to_fit();
}
/// \brief Inserts a new element at a specific position in the array.
@@ -588,9 +588,6 @@ TOML_NAMESPACE_START
/// \param val The node or value being inserted.
/// \param flags Value flags to apply to new values.
///
- /// \note When `flags == value_flags::none` and `val` is a value node or node_view, any existing value
- /// flags will be copied, _not_ set to none.
- ///
/// \returns \conditional_return{Valid input}
/// An iterator to the newly-inserted element.
/// \conditional_return{Input is an empty toml::node_view}
@@ -599,14 +596,14 @@ TOML_NAMESPACE_START
/// \attention The return value will always be `end()` if the input value was an empty toml::node_view,
/// because no insertion can take place. This is the only circumstance in which this can occur.
template
- iterator insert(const_iterator pos, ElemType&& val, value_flags flags = value_flags::none)
+ iterator insert(const_iterator pos, ElemType&& val, value_flags flags = preserve_source_value_flags)
{
if constexpr (is_node_view)
{
if (!val)
return end();
}
- return { elements.emplace(pos.raw_, impl::make_node(static_cast(val), flags)) };
+ return { elems_.emplace(pos.raw_, impl::make_node(static_cast(val), flags)) };
}
/// \brief Repeatedly inserts a new element starting at a specific position in the array.
@@ -638,9 +635,6 @@ TOML_NAMESPACE_START
/// \param val The node or value being inserted.
/// \param flags Value flags to apply to new values.
///
- /// \note When `flags == value_flags::none` and `val` is a value node or node_view, any existing value
- /// flags will be copied, _not_ set to none.
- ///
/// \returns \conditional_return{Valid input}
/// An iterator to the newly-inserted element.
/// \conditional_return{count == 0}
@@ -651,7 +645,10 @@ TOML_NAMESPACE_START
/// \attention The return value will always be `end()` if the input value was an empty toml::node_view,
/// because no insertion can take place. This is the only circumstance in which this can occur.
template
- iterator insert(const_iterator pos, size_t count, ElemType&& val, value_flags flags = value_flags::none)
+ iterator insert(const_iterator pos,
+ size_t count,
+ ElemType&& val,
+ value_flags flags = preserve_source_value_flags)
{
if constexpr (is_node_view)
{
@@ -660,19 +657,19 @@ TOML_NAMESPACE_START
}
switch (count)
{
- case 0: return { elements.begin() + (pos.raw_ - elements.cbegin()) };
+ case 0: return { elems_.begin() + (pos.raw_ - elems_.cbegin()) };
case 1: return insert(pos, static_cast(val), flags);
default:
{
- const auto start_idx = static_cast(pos.raw_ - elements.cbegin());
+ const auto start_idx = static_cast(pos.raw_ - elems_.cbegin());
preinsertion_resize(start_idx, count);
size_t i = start_idx;
for (size_t e = start_idx + count - 1u; i < e; i++)
- elements[i].reset(impl::make_node(val, flags));
+ elems_[i].reset(impl::make_node(val, flags));
//# potentially move the initial value into the last element
- elements[i].reset(impl::make_node(static_cast(val), flags));
- return { elements.begin() + static_cast(start_idx) };
+ elems_[i].reset(impl::make_node(static_cast(val), flags));
+ return { elems_.begin() + static_cast(start_idx) };
}
}
}
@@ -685,9 +682,6 @@ TOML_NAMESPACE_START
/// \param last Iterator to the one-past-the-last node or value being inserted.
/// \param flags Value flags to apply to new values.
///
- /// \note When `flags == value_flags::none` and a source value is a value node or node_view, any existing value
- /// flags will be copied, _not_ set to none.
- ///
/// \returns \conditional_return{Valid input}
/// An iterator to the first newly-inserted element.
/// \conditional_return{first >= last}
@@ -695,11 +689,11 @@ TOML_NAMESPACE_START
/// \conditional_return{All objects in the range were empty toml::node_views}
/// A copy of pos
template
- iterator insert(const_iterator pos, Iter first, Iter last, value_flags flags = value_flags::none)
+ iterator insert(const_iterator pos, Iter first, Iter last, value_flags flags = preserve_source_value_flags)
{
const auto distance = std::distance(first, last);
if (distance <= 0)
- return { elements.begin() + (pos.raw_ - elements.cbegin()) };
+ return { elems_.begin() + (pos.raw_ - elems_.cbegin()) };
else
{
auto count = distance;
@@ -710,9 +704,9 @@ TOML_NAMESPACE_START
if (!(*it))
count--;
if (!count)
- return { elements.begin() + (pos.raw_ - elements.cbegin()) };
+ return { elems_.begin() + (pos.raw_ - elems_.cbegin()) };
}
- const auto start_idx = static_cast(pos.raw_ - elements.cbegin());
+ const auto start_idx = static_cast(pos.raw_ - elems_.cbegin());
preinsertion_resize(start_idx, static_cast(count));
size_t i = start_idx;
for (auto it = first; it != last; it++)
@@ -723,11 +717,11 @@ TOML_NAMESPACE_START
continue;
}
if constexpr (std::is_rvalue_reference_v)
- elements[i++].reset(impl::make_node(std::move(*it), flags));
+ elems_[i++].reset(impl::make_node(std::move(*it), flags));
else
- elements[i++].reset(impl::make_node(*it, flags));
+ elems_[i++].reset(impl::make_node(*it, flags));
}
- return { elements.begin() + static_cast(start_idx) };
+ return { elems_.begin() + static_cast(start_idx) };
}
}
@@ -739,9 +733,6 @@ TOML_NAMESPACE_START
/// \param ilist An initializer list containing the values to be inserted.
/// \param flags Value flags to apply to new values.
///
- /// \note When `flags == value_flags::none` and a source value is a value node or node_view, any existing value
- /// flags will be copied, _not_ set to none.
- ///
/// \returns \conditional_return{Valid input}
/// An iterator to the first newly-inserted element.
/// \conditional_return{Input list is empty}
@@ -751,7 +742,7 @@ TOML_NAMESPACE_START
template
iterator insert(const_iterator pos,
std::initializer_list ilist,
- value_flags flags = value_flags::none)
+ value_flags flags = preserve_source_value_flags)
{
return insert(pos, ilist.begin(), ilist.end(), flags);
}
@@ -787,7 +778,7 @@ TOML_NAMESPACE_START
static_assert((impl::is_native || impl::is_one_of)&&!impl::is_cvref,
"Emplacement type parameter must be one of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
- return { elements.emplace(pos.raw_, new impl::wrap_node{ static_cast(args)... }) };
+ return { elems_.emplace(pos.raw_, new impl::wrap_node{ static_cast(args)... }) };
}
/// \brief Removes the specified element from the array.
@@ -811,7 +802,7 @@ TOML_NAMESPACE_START
/// \returns Iterator to the first element immediately following the removed element.
iterator erase(const_iterator pos) noexcept
{
- return { elements.erase(pos.raw_) };
+ return { elems_.erase(pos.raw_) };
}
/// \brief Removes the elements in the range [first, last) from the array.
@@ -836,7 +827,7 @@ TOML_NAMESPACE_START
/// \returns Iterator to the first element immediately following the last removed element.
iterator erase(const_iterator first, const_iterator last) noexcept
{
- return { elements.erase(first.raw_, last.raw_) };
+ return { elems_.erase(first.raw_, last.raw_) };
}
/// \brief Resizes the array.
@@ -873,11 +864,11 @@ TOML_NAMESPACE_START
"The default element type argument to toml::array::resize may not be toml::node_view.");
if (!new_size)
- elements.clear();
- else if (new_size < elements.size())
- elements.resize(new_size);
- else if (new_size > elements.size())
- insert(cend(), new_size - elements.size(), static_cast(default_init_val));
+ elems_.clear();
+ else if (new_size < elems_.size())
+ elems_.resize(new_size);
+ else if (new_size > elems_.size())
+ insert(cend(), new_size - elems_.size(), static_cast(default_init_val));
}
/// \brief Shrinks the array to the given size.
@@ -905,8 +896,8 @@ TOML_NAMESPACE_START
/// \remarks Does nothing if the requested size is larger than or equal to the current size.
void truncate(size_t new_size)
{
- if (new_size < elements.size())
- elements.resize(new_size);
+ if (new_size < elems_.size())
+ elems_.resize(new_size);
}
/// \brief Appends a new element to the end of the array.
@@ -928,13 +919,10 @@ TOML_NAMESPACE_START
/// \param val The node or value being added.
/// \param flags Value flags to apply to new values.
///
- /// \note When `flags == value_flags::none` and `val` is a value node or node_view, any existing value
- /// flags will be copied, _not_ set to none.
- ///
/// \attention No insertion takes place if the input value is an empty toml::node_view.
/// This is the only circumstance in which this can occur.
template
- void push_back(ElemType&& val, value_flags flags = value_flags::none)
+ void push_back(ElemType&& val, value_flags flags = preserve_source_value_flags)
{
emplace_back_if_not_empty_view(static_cast(val), flags);
}
@@ -968,14 +956,14 @@ TOML_NAMESPACE_START
"Emplacement type parameter must be one of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
auto nde = new impl::wrap_node{ static_cast(args)... };
- elements.emplace_back(nde);
+ elems_.emplace_back(nde);
return *nde;
}
/// \brief Removes the last element from the array.
void pop_back() noexcept
{
- elements.pop_back();
+ elems_.pop_back();
}
/// \brief Gets the element at a specific index.
@@ -1003,7 +991,7 @@ TOML_NAMESPACE_START
TOML_NODISCARD
node* get(size_t index) noexcept
{
- return index < elements.size() ? elements[index].get() : nullptr;
+ return index < elems_.size() ? elems_[index].get() : nullptr;
}
/// \brief Gets the element at a specific index (const overload).
@@ -1014,7 +1002,7 @@ TOML_NAMESPACE_START
TOML_NODISCARD
const node* get(size_t index) const noexcept
{
- return index < elements.size() ? elements[index].get() : nullptr;
+ return index < elems_.size() ? elems_[index].get() : nullptr;
}
/// \brief Gets the element at a specific index if it is a particular type.
diff --git a/include/toml++/impl/array.inl b/include/toml++/impl/array.inl
index 8766dce..5e61e08 100644
--- a/include/toml++/impl/array.inl
+++ b/include/toml++/impl/array.inl
@@ -46,9 +46,9 @@ TOML_NAMESPACE_START
array::array(const array& other) //
: node(other)
{
- elements.reserve(other.elements.size());
+ elems_.reserve(other.elems_.size());
for (const auto& elem : other)
- elements.emplace_back(impl::make_node(elem));
+ elems_.emplace_back(impl::make_node(elem));
#if TOML_LIFETIME_HOOKS
TOML_ARRAY_CREATED;
@@ -58,7 +58,7 @@ TOML_NAMESPACE_START
TOML_EXTERNAL_LINKAGE
array::array(array && other) noexcept //
: node(std::move(other)),
- elements{ std::move(other.elements) }
+ elems_{ std::move(other.elems_) }
{
#if TOML_LIFETIME_HOOKS
TOML_ARRAY_CREATED;
@@ -71,10 +71,10 @@ TOML_NAMESPACE_START
if (&rhs != this)
{
node::operator=(rhs);
- elements.clear();
- elements.reserve(rhs.elements.size());
+ elems_.clear();
+ elems_.reserve(rhs.elems_.size());
for (const auto& elem : rhs)
- elements.emplace_back(impl::make_node(elem));
+ elems_.emplace_back(impl::make_node(elem));
}
return *this;
}
@@ -85,7 +85,7 @@ TOML_NAMESPACE_START
if (&rhs != this)
{
node::operator=(std::move(rhs));
- elements = std::move(rhs.elements);
+ elems_ = std::move(rhs.elems_);
}
return *this;
}
@@ -93,29 +93,29 @@ TOML_NAMESPACE_START
TOML_EXTERNAL_LINKAGE
void array::preinsertion_resize(size_t idx, size_t count)
{
- TOML_ASSERT(idx <= elements.size());
+ TOML_ASSERT(idx <= elems_.size());
TOML_ASSERT(count >= 1u);
- const auto old_size = elements.size();
+ const auto old_size = elems_.size();
const auto new_size = old_size + count;
const auto inserting_at_end = idx == old_size;
- elements.resize(new_size);
+ elems_.resize(new_size);
if (!inserting_at_end)
{
for (size_t left = old_size, right = new_size - 1u; left-- > idx; right--)
- elements[right] = std::move(elements[left]);
+ elems_[right] = std::move(elems_[left]);
}
}
TOML_EXTERNAL_LINKAGE
bool array::is_homogeneous(node_type ntype) const noexcept
{
- if (elements.empty())
+ if (elems_.empty())
return false;
if (ntype == node_type::none)
- ntype = elements[0]->type();
+ ntype = elems_[0]->type();
- for (const auto& val : elements)
+ for (const auto& val : elems_)
if (val->type() != ntype)
return false;
@@ -125,13 +125,13 @@ TOML_NAMESPACE_START
TOML_EXTERNAL_LINKAGE
bool array::is_homogeneous(node_type ntype, node * &first_nonmatch) noexcept
{
- return TOML_ANON_NAMESPACE::array_is_homogeneous(elements, ntype, first_nonmatch);
+ return TOML_ANON_NAMESPACE::array_is_homogeneous(elems_, ntype, first_nonmatch);
}
TOML_EXTERNAL_LINKAGE
bool array::is_homogeneous(node_type ntype, const node*& first_nonmatch) const noexcept
{
- return TOML_ANON_NAMESPACE::array_is_homogeneous(elements, ntype, first_nonmatch);
+ return TOML_ANON_NAMESPACE::array_is_homogeneous(elems_, ntype, first_nonmatch);
}
TOML_EXTERNAL_LINKAGE
@@ -139,17 +139,17 @@ TOML_NAMESPACE_START
{
if (&lhs == &rhs)
return true;
- if (lhs.elements.size() != rhs.elements.size())
+ if (lhs.elems_.size() != rhs.elems_.size())
return false;
- for (size_t i = 0, e = lhs.elements.size(); i < e; i++)
+ for (size_t i = 0, e = lhs.elems_.size(); i < e; i++)
{
- const auto lhs_type = lhs.elements[i]->type();
- const node& rhs_ = *rhs.elements[i];
+ const auto lhs_type = lhs.elems_[i]->type();
+ const node& rhs_ = *rhs.elems_[i];
const auto rhs_type = rhs_.type();
if (lhs_type != rhs_type)
return false;
- const bool equal = lhs.elements[i]->visit(
+ const bool equal = lhs.elems_[i]->visit(
[&](const auto& lhs_) noexcept
{ return lhs_ == *reinterpret_cast*>(&rhs_); });
if (!equal)
@@ -162,9 +162,9 @@ TOML_NAMESPACE_START
size_t array::total_leaf_count() const noexcept
{
size_t leaves{};
- for (size_t i = 0, e = elements.size(); i < e; i++)
+ for (size_t i = 0, e = elems_.size(); i < e; i++)
{
- auto arr = elements[i]->as_array();
+ auto arr = elems_[i]->as_array();
leaves += arr ? arr->total_leaf_count() : size_t{ 1 };
}
return leaves;
@@ -175,29 +175,29 @@ TOML_NAMESPACE_START
{
for (size_t i = 0, e = child.size(); i < e; i++)
{
- auto type = child.elements[i]->type();
+ auto type = child.elems_[i]->type();
if (type == node_type::array)
{
- array& arr = *reinterpret_cast(child.elements[i].get());
+ array& arr = *reinterpret_cast(child.elems_[i].get());
if (!arr.empty())
flatten_child(std::move(arr), dest_index);
}
else
- elements[dest_index++] = std::move(child.elements[i]);
+ elems_[dest_index++] = std::move(child.elems_[i]);
}
}
TOML_EXTERNAL_LINKAGE
array& array::flatten()&
{
- if (elements.empty())
+ if (elems_.empty())
return *this;
bool requires_flattening = false;
- size_t size_after_flattening = elements.size();
- for (size_t i = elements.size(); i-- > 0u;)
+ size_t size_after_flattening = elems_.size();
+ for (size_t i = elems_.size(); i-- > 0u;)
{
- auto arr = elements[i]->as_array();
+ auto arr = elems_[i]->as_array();
if (!arr)
continue;
size_after_flattening--; // discount the array itself
@@ -208,25 +208,25 @@ TOML_NAMESPACE_START
size_after_flattening += leaf_count;
}
else
- elements.erase(elements.cbegin() + static_cast(i));
+ elems_.erase(elems_.cbegin() + static_cast(i));
}
if (!requires_flattening)
return *this;
- elements.reserve(size_after_flattening);
+ elems_.reserve(size_after_flattening);
size_t i = 0;
- while (i < elements.size())
+ while (i < elems_.size())
{
- auto arr = elements[i]->as_array();
+ auto arr = elems_[i]->as_array();
if (!arr)
{
i++;
continue;
}
- std::unique_ptr arr_storage = std::move(elements[i]);
+ std::unique_ptr arr_storage = std::move(elems_[i]);
const auto leaf_count = arr->total_leaf_count();
if (leaf_count > 1u)
preinsertion_resize(i + 1u, leaf_count - 1u);
diff --git a/include/toml++/impl/forward_declarations.h b/include/toml++/impl/forward_declarations.h
index 08f2a5d..5f21d57 100644
--- a/include/toml++/impl/forward_declarations.h
+++ b/include/toml++/impl/forward_declarations.h
@@ -283,6 +283,11 @@ TOML_NAMESPACE_START // abi namespace
};
TOML_MAKE_FLAGS(value_flags);
+ /// \brief Special #toml::value_flags constant used for array + table insert functions to specify that any value
+ /// nodes being copied should not have their flags property overridden by the inserting function's `flags` argument.
+ inline constexpr value_flags preserve_source_value_flags =
+ POXY_IMPLEMENTATION_DETAIL(value_flags{ static_cast>(-1) });
+
/// \brief Format flags for modifying how TOML data is printed to streams.
///
/// \note Formatters may disregard/override any of these flags according to the requirements of their
@@ -868,9 +873,7 @@ TOML_NAMESPACE_END;
TOML_IMPL_NAMESPACE_START
{
template
- TOML_NODISCARD
- TOML_ATTR(const)
- TOML_ALWAYS_INLINE
+ TOML_CONST_INLINE_GETTER
constexpr std::underlying_type_t unwrap_enum(T val) noexcept
{
return static_cast>(val);
@@ -886,8 +889,7 @@ TOML_IMPL_NAMESPACE_START
nan
};
- TOML_NODISCARD
- TOML_ATTR(pure)
+ TOML_PURE_GETTER
inline fp_class fpclassify(const double& val) noexcept
{
static_assert(sizeof(uint64_t) == sizeof(double));
@@ -897,7 +899,7 @@ TOML_IMPL_NAMESPACE_START
static constexpr uint64_t mantissa = 0b0000000000001111111111111111111111111111111111111111111111111111ull;
uint64_t val_bits;
- memcpy(&val_bits, &val, sizeof(val));
+ std::memcpy(&val_bits, &val, sizeof(val));
if ((val_bits & exponent) != exponent)
return fp_class::ok;
if ((val_bits & mantissa))
@@ -909,7 +911,7 @@ TOML_IMPL_NAMESPACE_START
// A: Because is _huge_ and std::find would be the only thing I used from it.
// I don't want to impose such a heavy compile-time burden on users.
template
- TOML_NODISCARD
+ TOML_PURE_GETTER
inline auto find(Iterator start, Iterator end, const T& needle) noexcept //
->decltype(&(*start))
{
diff --git a/include/toml++/impl/header_start.h b/include/toml++/impl/header_start.h
index 8682f1d..edeea8c 100644
--- a/include/toml++/impl/header_start.h
+++ b/include/toml++/impl/header_start.h
@@ -4,5 +4,3 @@
#endif
//# }}
TOML_PUSH_WARNINGS;
-TOML_DISABLE_SPAM_WARNINGS;
-TOML_DISABLE_SWITCH_WARNINGS;
diff --git a/include/toml++/impl/make_node.h b/include/toml++/impl/make_node.h
index 55a4674..72ae48a 100644
--- a/include/toml++/impl/make_node.h
+++ b/include/toml++/impl/make_node.h
@@ -37,11 +37,6 @@ TOML_IMPL_NAMESPACE_START
if constexpr (std::is_same_v, value_type>)
{
out = new value_type{ static_cast(val) };
-
- // only override the flags if the new ones are nonzero
- // (so the copy/move ctor does the right thing in the general case)
- if (flags != value_flags::none)
- out->flags(flags);
}
// creating from raw value
@@ -63,17 +58,18 @@ TOML_IMPL_NAMESPACE_START
}
else
out = new value_type{ static_cast(val) };
-
- out->flags(flags);
}
+ if (flags != preserve_source_value_flags)
+ out->flags(flags);
+
return out;
}
}
template
TOML_NODISCARD
- auto* make_node(T && val, value_flags flags = value_flags::none)
+ auto* make_node(T && val, value_flags flags = preserve_source_value_flags)
{
using type = unwrap_node>;
if constexpr (std::is_same_v || is_node_view)
@@ -96,7 +92,7 @@ TOML_IMPL_NAMESPACE_START
template
TOML_NODISCARD
- auto* make_node(inserter && val, value_flags flags = value_flags::none)
+ auto* make_node(inserter && val, value_flags flags = preserve_source_value_flags)
{
return make_node(static_cast(val.value), flags);
}
diff --git a/include/toml++/impl/parser.inl b/include/toml++/impl/parser.inl
index 4a3a4a5..1845cd8 100644
--- a/include/toml++/impl/parser.inl
+++ b/include/toml++/impl/parser.inl
@@ -81,22 +81,19 @@ TOML_ANON_NAMESPACE_START
position_ += 3u;
}
- TOML_NODISCARD
- TOML_ALWAYS_INLINE
+ TOML_PURE_INLINE_GETTER
constexpr bool eof() const noexcept
{
return position_ >= source_.length();
}
- TOML_NODISCARD
- TOML_ALWAYS_INLINE
+ TOML_PURE_INLINE_GETTER
constexpr bool peek_eof() const noexcept
{
return eof();
}
- TOML_NODISCARD
- TOML_ALWAYS_INLINE
+ TOML_CONST_INLINE_GETTER
constexpr bool error() const noexcept
{
return false;
@@ -138,14 +135,12 @@ TOML_ANON_NAMESPACE_START
}
TOML_NODISCARD
- TOML_ALWAYS_INLINE
bool eof() const noexcept
{
return source_->eof();
}
TOML_NODISCARD
- TOML_ALWAYS_INLINE
bool peek_eof() const
{
using stream_traits = typename std::remove_pointer_t::traits_type;
@@ -153,7 +148,6 @@ TOML_ANON_NAMESPACE_START
}
TOML_NODISCARD
- TOML_ALWAYS_INLINE
bool error() const noexcept
{
return !(*source_);
@@ -175,21 +169,19 @@ TOML_ANON_NAMESPACE_START
char bytes[4];
source_position position;
- TOML_NODISCARD
+ TOML_PURE_GETTER
std::string_view as_view() const noexcept
{
return bytes[3] ? std::string_view{ bytes, 4u } : std::string_view{ bytes };
}
- TOML_NODISCARD
- TOML_ATTR(pure)
+ TOML_PURE_GETTER
constexpr operator const char32_t&() const noexcept
{
return value;
}
- TOML_NODISCARD
- TOML_ATTR(pure)
+ TOML_PURE_GETTER
constexpr const char32_t& operator*() const noexcept
{
return value;
@@ -3025,9 +3017,9 @@ TOML_IMPL_NAMESPACE_START
{
// table arrays are a special case;
// the spec dictates we select the most recently declared element in the array.
- TOML_ASSERT(!child->ref_cast().elements.empty());
- TOML_ASSERT(child->ref_cast().elements.back()->is_table());
- parent = &child->ref_cast().elements.back()->ref_cast();
+ TOML_ASSERT(!child->ref_cast().elems_.empty());
+ TOML_ASSERT(child->ref_cast().elems_.back()->is_table());
+ parent = &child->ref_cast().elems_.back()->ref_cast();
}
else
{
@@ -3060,9 +3052,9 @@ TOML_IMPL_NAMESPACE_START
table_arrays.push_back(tab_arr);
tab_arr->source_ = { header_begin_pos, header_end_pos, reader.source_path() };
- tab_arr->elements.emplace_back(new table{});
- tab_arr->elements.back()->source_ = { header_begin_pos, header_end_pos, reader.source_path() };
- return &tab_arr->elements.back()->ref_cast();
+ tab_arr->elems_.emplace_back(new table{});
+ tab_arr->elems_.back()->source_ = { header_begin_pos, header_end_pos, reader.source_path() };
+ return &tab_arr->elems_.back()->ref_cast();
}
// otherwise we're just making a table
@@ -3084,9 +3076,9 @@ TOML_IMPL_NAMESPACE_START
&& impl::find(table_arrays.begin(), table_arrays.end(), &matching_node->ref_cast()))
{
auto tab_arr = &matching_node->ref_cast();
- tab_arr->elements.emplace_back(new table{});
- tab_arr->elements.back()->source_ = { header_begin_pos, header_end_pos, reader.source_path() };
- return &tab_arr->elements.back()->ref_cast();
+ tab_arr->elems_.emplace_back(new table{});
+ tab_arr->elems_.back()->source_ = { header_begin_pos, header_end_pos, reader.source_path() };
+ return &tab_arr->elems_.back()->ref_cast();
}
else if (!is_arr && matching_node->is_table() && !implicit_tables.empty())
@@ -3264,7 +3256,7 @@ TOML_IMPL_NAMESPACE_START
{
auto& arr = nde.ref_cast();
auto end = nde.source_.end;
- for (auto& v : arr.elements)
+ for (auto& v : arr.elems_)
{
update_region_ends(*v);
if (end < v->source_.end)
@@ -3328,7 +3320,7 @@ TOML_IMPL_NAMESPACE_START
advance_and_return_if_error_or_eof({});
node_ptr arr{ new array{} };
- auto& vals = reinterpret_cast(arr.get())->elements;
+ auto& vals = reinterpret_cast(arr.get())->elems_;
enum parse_elem : int
{
none,
diff --git a/include/toml++/impl/table.h b/include/toml++/impl/table.h
index 0143da0..fea677d 100644
--- a/include/toml++/impl/table.h
+++ b/include/toml++/impl/table.h
@@ -159,21 +159,21 @@ TOML_IMPL_NAMESPACE_START
template
TOML_NODISCARD_CTOR
- table_init_pair(std::string&& k, V&& v, value_flags flags = value_flags::none) //
+ table_init_pair(std::string&& k, V&& v, value_flags flags = preserve_source_value_flags) //
: key{ std::move(k) },
value{ make_node(static_cast(v), flags) }
{}
template
TOML_NODISCARD_CTOR
- table_init_pair(std::string_view k, V&& v, value_flags flags = value_flags::none) //
+ table_init_pair(std::string_view k, V&& v, value_flags flags = preserve_source_value_flags) //
: key{ k },
value{ make_node(static_cast(v), flags) }
{}
template
TOML_NODISCARD_CTOR
- table_init_pair(const char* k, V&& v, value_flags flags = value_flags::none) //
+ table_init_pair(const char* k, V&& v, value_flags flags = preserve_source_value_flags) //
: key{ k },
value{ make_node(static_cast(v), flags) }
{}
@@ -182,21 +182,21 @@ TOML_IMPL_NAMESPACE_START
template
TOML_NODISCARD_CTOR
- table_init_pair(std::wstring&& k, V&& v, value_flags flags = value_flags::none) //
+ table_init_pair(std::wstring&& k, V&& v, value_flags flags = preserve_source_value_flags) //
: key{ narrow(k) },
value{ make_node(static_cast(v), flags) }
{}
template
TOML_NODISCARD_CTOR
- table_init_pair(std::wstring_view k, V&& v, value_flags flags = value_flags::none) //
+ table_init_pair(std::wstring_view k, V&& v, value_flags flags = preserve_source_value_flags) //
: key{ narrow(k) },
value{ make_node(static_cast(v), flags) }
{}
template
TOML_NODISCARD_CTOR
- table_init_pair(const wchar_t* k, V&& v, value_flags flags = value_flags::none) //
+ table_init_pair(const wchar_t* k, V&& v, value_flags flags = preserve_source_value_flags) //
: key{ narrow(std::wstring_view{ k }) },
value{ make_node(static_cast(v), flags) }
{}
@@ -652,9 +652,6 @@ TOML_NAMESPACE_START
/// \param val The new value to insert.
/// \param flags Value flags to apply to new values.
///
- /// \note When `flags == value_flags::none` and `val` is a value node or node_view, any existing value
- /// flags will be copied, _not_ set to none.
- ///
/// \returns \conditional_return{Valid input}
///
/// - An iterator to the insertion position (or the position of the value that prevented insertion)
@@ -669,7 +666,9 @@ TOML_NAMESPACE_START
TOML_CONSTRAINED_TEMPLATE((std::is_convertible_v || impl::is_wide_string),
typename KeyType,
typename ValueType)
- std::pair insert(KeyType&& key, ValueType&& val, value_flags flags = value_flags::none)
+ std::pair insert(KeyType&& key,
+ ValueType&& val,
+ value_flags flags = preserve_source_value_flags)
{
static_assert(
!impl::is_wide_string || TOML_WINDOWS_COMPAT,
@@ -740,15 +739,12 @@ TOML_NAMESPACE_START
/// \param last An iterator to one-past-the-last value in the input collection.
/// \param flags Value flags to apply to new values.
///
- /// \note When `flags == value_flags::none` and a source value is a value node or node_view, any existing value
- /// flags will be copied, _not_ set to none.
- ///
/// \remarks This function is morally equivalent to calling `insert(key, value)` for each
/// key-value pair covered by the iterator range, so any values with keys already found in the
/// table will not be replaced.
TOML_CONSTRAINED_TEMPLATE((!std::is_convertible_v && !impl::is_wide_string),
typename Iter)
- void insert(Iter first, Iter last, value_flags flags = value_flags::none)
+ void insert(Iter first, Iter last, value_flags flags = preserve_source_value_flags)
{
if (first == last)
return;
@@ -803,9 +799,6 @@ TOML_NAMESPACE_START
/// \param val The value to insert/assign.
/// \param flags Value flags to apply to new values.
///
- /// \note When `flags == value_flags::none` and `val` is a value node or node_view, any existing value
- /// flags will be copied, _not_ set to none.
- ///
/// \returns \conditional_return{Valid input}
///
/// - An iterator to the value's position
@@ -820,7 +813,7 @@ TOML_NAMESPACE_START
template
std::pair insert_or_assign(KeyType&& key,
ValueType&& val,
- value_flags flags = value_flags::none)
+ value_flags flags = preserve_source_value_flags)
{
static_assert(
!impl::is_wide_string || TOML_WINDOWS_COMPAT,
diff --git a/include/toml++/toml.h b/include/toml++/toml.h
index 2956599..869337a 100644
--- a/include/toml++/toml.h
+++ b/include/toml++/toml.h
@@ -13,6 +13,8 @@
#include "impl/preprocessor.h"
TOML_PUSH_WARNINGS;
+TOML_DISABLE_SPAM_WARNINGS;
+TOML_DISABLE_SWITCH_WARNINGS;
#if TOML_MSVC
#pragma warning(disable : 5031) // #pragma warning(pop): likely mismatch (false-positive)
#elif TOML_CLANG && !TOML_HEADER_ONLY && TOML_IMPLEMENTATION
diff --git a/toml++.natvis b/toml++.natvis
index e2549e3..0cc50d2 100644
--- a/toml++.natvis
+++ b/toml++.natvis
@@ -1,7 +1,7 @@
-
+
@@ -20,7 +20,7 @@
-
+
@@ -40,7 +40,7 @@
-
+
@@ -58,7 +58,8 @@
-
+
+
{date}T{time}{offset}
{date}T{time}
@@ -68,21 +69,21 @@
-
+
{{ {val_} }}
- val_
-
+
{{ {val_,s8} }}
- val_,s8
-
+
line {line}, column {column}
- line
@@ -90,17 +91,13 @@
-
- {&bytes,s8} ({position})
-
-
-
- {map}
+
+ {map_}
- map._Mypair._Myval2._Myval2._Mysize
- map._Mypair._Myval2._Myval2._Myhead->_Parent
+ map_._Mypair._Myval2._Myval2._Mysize
+ map_._Mypair._Myval2._Myval2._Myhead->_Parent
_Left
_Right
*_Myval.second
@@ -108,31 +105,31 @@
-
- {elements}
+
+ {elems_}
- elements._Mypair._Myval2._Mylast - elements._Mypair._Myval2._Myfirst
- *elements._Mypair._Myval2._Myfirst[$i]
+ elems_._Mypair._Myval2._Mylast - elems_._Mypair._Myval2._Myfirst
+ *elems_._Mypair._Myval2._Myfirst[$i]
-
+
line {source_.begin.line}: {description_,s8b}
-
+
line {source_.begin.line}: {_Data._What,s8b}
-
- {*reinterpret_cast<toml::v2::table*>(&storage_.bytes)}
- {*reinterpret_cast<toml::v2::noex::parse_error*>(&storage_.bytes)}
+
+ {*reinterpret_cast<toml::v3::table*>(&storage_.bytes)}
+ {*reinterpret_cast<toml::v3::noex::parse_error*>(&storage_.bytes)}
- - *reinterpret_cast<toml::v2::table*>(&storage_.bytes)
- - *reinterpret_cast<toml::v2::noex::parse_error*>(&storage_.bytes)
+ - *reinterpret_cast<toml::v3::table*>(&storage_.bytes)
+ - *reinterpret_cast<toml::v3::noex::parse_error*>(&storage_.bytes)
diff --git a/toml++.vcxproj b/toml++.vcxproj
index e4cd42b..f3f45ba 100644
--- a/toml++.vcxproj
+++ b/toml++.vcxproj
@@ -82,6 +82,10 @@
+
+
+
+
diff --git a/toml++.vcxproj.filters b/toml++.vcxproj.filters
index 1d40174..a47eefd 100644
--- a/toml++.vcxproj.filters
+++ b/toml++.vcxproj.filters
@@ -183,6 +183,18 @@
include\impl
+
+ .github
+
+
+ .github
+
+
+ .github
+
+
+ .github
+
@@ -206,6 +218,9 @@
{4e42aaa3-98cd-4678-9c1c-ffa3eaf519d7}
+
+ {e3ab5e86-e053-48a6-9fee-f6442a63aaa6}
+
diff --git a/toml.hpp b/toml.hpp
index 1a2f2b6..c3f7be0 100644
--- a/toml.hpp
+++ b/toml.hpp
@@ -871,6 +871,8 @@ TOML_ENABLE_WARNINGS;
// clang-format on
TOML_PUSH_WARNINGS;
+TOML_DISABLE_SPAM_WARNINGS;
+TOML_DISABLE_SWITCH_WARNINGS;
#if TOML_MSVC
#pragma warning(disable : 5031) // #pragma warning(pop): likely mismatch (false-positive)
#elif TOML_CLANG && !TOML_HEADER_ONLY && TOML_IMPLEMENTATION
@@ -968,9 +970,6 @@ TOML_NAMESPACE_END;
//******** impl/forward_declarations.h *******************************************************************************
TOML_PUSH_WARNINGS;
-TOML_DISABLE_SPAM_WARNINGS;
-TOML_DISABLE_SWITCH_WARNINGS;
-
TOML_DISABLE_WARNINGS;
#include
#include
@@ -1181,6 +1180,9 @@ TOML_NAMESPACE_START // abi namespace
};
TOML_MAKE_FLAGS(value_flags);
+ inline constexpr value_flags preserve_source_value_flags =
+ POXY_IMPLEMENTATION_DETAIL(value_flags{ static_cast>(-1) });
+
enum class format_flags : uint64_t
{
none,
@@ -1708,9 +1710,7 @@ TOML_NAMESPACE_END;
TOML_IMPL_NAMESPACE_START
{
template
- TOML_NODISCARD
- TOML_ATTR(const)
- TOML_ALWAYS_INLINE
+ TOML_CONST_INLINE_GETTER
constexpr std::underlying_type_t unwrap_enum(T val) noexcept
{
return static_cast>(val);
@@ -1726,8 +1726,7 @@ TOML_IMPL_NAMESPACE_START
nan
};
- TOML_NODISCARD
- TOML_ATTR(pure)
+ TOML_PURE_GETTER
inline fp_class fpclassify(const double& val) noexcept
{
static_assert(sizeof(uint64_t) == sizeof(double));
@@ -1737,7 +1736,7 @@ TOML_IMPL_NAMESPACE_START
static constexpr uint64_t mantissa = 0b0000000000001111111111111111111111111111111111111111111111111111ull;
uint64_t val_bits;
- memcpy(&val_bits, &val, sizeof(val));
+ std::memcpy(&val_bits, &val, sizeof(val));
if ((val_bits & exponent) != exponent)
return fp_class::ok;
if ((val_bits & mantissa))
@@ -1749,7 +1748,7 @@ TOML_IMPL_NAMESPACE_START
// A: Because is _huge_ and std::find would be the only thing I used from it.
// I don't want to impose such a heavy compile-time burden on users.
template
- TOML_NODISCARD
+ TOML_PURE_GETTER
inline auto find(Iterator start, Iterator end, const T& needle) noexcept //
->decltype(&(*start))
{
@@ -1766,8 +1765,6 @@ TOML_POP_WARNINGS;
//******** impl/print_to_stream.h ************************************************************************************
TOML_PUSH_WARNINGS;
-TOML_DISABLE_SPAM_WARNINGS;
-TOML_DISABLE_SWITCH_WARNINGS;
TOML_IMPL_NAMESPACE_START
{
@@ -1901,8 +1898,6 @@ TOML_POP_WARNINGS;
//******** impl/source_region.h **************************************************************************************
TOML_PUSH_WARNINGS;
-TOML_DISABLE_SPAM_WARNINGS;
-TOML_DISABLE_SWITCH_WARNINGS;
TOML_NAMESPACE_START
{
@@ -1987,8 +1982,6 @@ TOML_POP_WARNINGS;
//******** impl/date_time.h ******************************************************************************************
TOML_PUSH_WARNINGS;
-TOML_DISABLE_SPAM_WARNINGS;
-TOML_DISABLE_SWITCH_WARNINGS;
TOML_NAMESPACE_START
{
@@ -2273,8 +2266,6 @@ TOML_POP_WARNINGS;
//******** impl/node.h ***********************************************************************************************
TOML_PUSH_WARNINGS;
-TOML_DISABLE_SPAM_WARNINGS;
-TOML_DISABLE_SWITCH_WARNINGS;
TOML_NAMESPACE_START
{
@@ -2868,10 +2859,7 @@ TOML_DISABLE_WARNINGS;
#include
#include
TOML_ENABLE_WARNINGS;
-
TOML_PUSH_WARNINGS;
-TOML_DISABLE_SPAM_WARNINGS;
-TOML_DISABLE_SWITCH_WARNINGS;
TOML_DISABLE_ARITHMETIC_WARNINGS;
TOML_NAMESPACE_START
@@ -3391,8 +3379,6 @@ TOML_POP_WARNINGS;
//******** impl/value.h **********************************************************************************************
TOML_PUSH_WARNINGS;
-TOML_DISABLE_SPAM_WARNINGS;
-TOML_DISABLE_SWITCH_WARNINGS;
TOML_DISABLE_ARITHMETIC_WARNINGS;
// clang-format off
@@ -4424,8 +4410,6 @@ TOML_POP_WARNINGS;
//******** impl/make_node.h ******************************************************************************************
TOML_PUSH_WARNINGS;
-TOML_DISABLE_SPAM_WARNINGS;
-TOML_DISABLE_SWITCH_WARNINGS;
TOML_IMPL_NAMESPACE_START
{
@@ -4456,11 +4440,6 @@ TOML_IMPL_NAMESPACE_START
if constexpr (std::is_same_v, value_type>)
{
out = new value_type{ static_cast(val) };
-
- // only override the flags if the new ones are nonzero
- // (so the copy/move ctor does the right thing in the general case)
- if (flags != value_flags::none)
- out->flags(flags);
}
// creating from raw value
@@ -4482,17 +4461,18 @@ TOML_IMPL_NAMESPACE_START
}
else
out = new value_type{ static_cast(val) };
-
- out->flags(flags);
}
+ if (flags != preserve_source_value_flags)
+ out->flags(flags);
+
return out;
}
}
template
TOML_NODISCARD
- auto* make_node(T && val, value_flags flags = value_flags::none)
+ auto* make_node(T && val, value_flags flags = preserve_source_value_flags)
{
using type = unwrap_node>;
if constexpr (std::is_same_v || is_node_view)
@@ -4515,7 +4495,7 @@ TOML_IMPL_NAMESPACE_START
template
TOML_NODISCARD
- auto* make_node(inserter && val, value_flags flags = value_flags::none)
+ auto* make_node(inserter && val, value_flags flags = preserve_source_value_flags)
{
return make_node(static_cast(val.value), flags);
}
@@ -4552,8 +4532,6 @@ TOML_POP_WARNINGS;
//******** impl/array.h **********************************************************************************************
TOML_PUSH_WARNINGS;
-TOML_DISABLE_SPAM_WARNINGS;
-TOML_DISABLE_SWITCH_WARNINGS;
TOML_IMPL_NAMESPACE_START
{
@@ -4738,7 +4716,7 @@ TOML_NAMESPACE_START
private:
friend class TOML_PARSER_TYPENAME;
- std::vector> elements;
+ std::vector> elems_;
TOML_API
void preinsertion_resize(size_t idx, size_t count);
@@ -4751,7 +4729,7 @@ TOML_NAMESPACE_START
if (!val)
return;
}
- elements.emplace_back(impl::make_node(static_cast(val), flags));
+ elems_.emplace_back(impl::make_node(static_cast(val), flags));
}
TOML_NODISCARD
@@ -4812,11 +4790,11 @@ TOML_NAMESPACE_START
TOML_NODISCARD_CTOR
explicit array(ElemType&& val, ElemTypes&&... vals)
{
- elements.reserve(sizeof...(ElemTypes) + 1u);
- emplace_back_if_not_empty_view(static_cast(val), value_flags::none);
+ elems_.reserve(sizeof...(ElemTypes) + 1u);
+ emplace_back_if_not_empty_view(static_cast(val), preserve_source_value_flags);
if constexpr (sizeof...(ElemTypes) > 0)
{
- (emplace_back_if_not_empty_view(static_cast(vals), value_flags::none), ...);
+ (emplace_back_if_not_empty_view(static_cast(vals), preserve_source_value_flags), ...);
}
#if TOML_LIFETIME_HOOKS
@@ -4882,127 +4860,130 @@ TOML_NAMESPACE_START
TOML_NODISCARD
node& operator[](size_t index) noexcept
{
- return *elements[index];
+ return *elems_[index];
}
TOML_NODISCARD
const node& operator[](size_t index) const noexcept
{
- return *elements[index];
+ return *elems_[index];
}
TOML_NODISCARD
node& front() noexcept
{
- return *elements.front();
+ return *elems_.front();
}
TOML_NODISCARD
const node& front() const noexcept
{
- return *elements.front();
+ return *elems_.front();
}
TOML_NODISCARD
node& back() noexcept
{
- return *elements.back();
+ return *elems_.back();
}
TOML_NODISCARD
const node& back() const noexcept
{
- return *elements.back();
+ return *elems_.back();
}
TOML_NODISCARD
iterator begin() noexcept
{
- return { elements.begin() };
+ return { elems_.begin() };
}
TOML_NODISCARD
const_iterator begin() const noexcept
{
- return { elements.cbegin() };
+ return { elems_.cbegin() };
}
TOML_NODISCARD
const_iterator cbegin() const noexcept
{
- return { elements.cbegin() };
+ return { elems_.cbegin() };
}
TOML_NODISCARD
iterator end() noexcept
{
- return { elements.end() };
+ return { elems_.end() };
}
TOML_NODISCARD
const_iterator end() const noexcept
{
- return { elements.cend() };
+ return { elems_.cend() };
}
TOML_NODISCARD
const_iterator cend() const noexcept
{
- return { elements.cend() };
+ return { elems_.cend() };
}
TOML_NODISCARD
bool empty() const noexcept
{
- return elements.empty();
+ return elems_.empty();
}
TOML_NODISCARD
size_t size() const noexcept
{
- return elements.size();
+ return elems_.size();
}
void reserve(size_t new_capacity)
{
- elements.reserve(new_capacity);
+ elems_.reserve(new_capacity);
}
void clear() noexcept
{
- elements.clear();
+ elems_.clear();
}
TOML_NODISCARD
size_t max_size() const noexcept
{
- return elements.max_size();
+ return elems_.max_size();
}
TOML_NODISCARD
size_t capacity() const noexcept
{
- return elements.capacity();
+ return elems_.capacity();
}
void shrink_to_fit()
{
- elements.shrink_to_fit();
+ elems_.shrink_to_fit();
}
template
- iterator insert(const_iterator pos, ElemType&& val, value_flags flags = value_flags::none)
+ iterator insert(const_iterator pos, ElemType&& val, value_flags flags = preserve_source_value_flags)
{
if constexpr (is_node_view)
{
if (!val)
return end();
}
- return { elements.emplace(pos.raw_, impl::make_node(static_cast(val), flags)) };
+ return { elems_.emplace(pos.raw_, impl::make_node(static_cast(val), flags)) };
}
template
- iterator insert(const_iterator pos, size_t count, ElemType&& val, value_flags flags = value_flags::none)
+ iterator insert(const_iterator pos,
+ size_t count,
+ ElemType&& val,
+ value_flags flags = preserve_source_value_flags)
{
if constexpr (is_node_view)
{
@@ -5011,28 +4992,28 @@ TOML_NAMESPACE_START
}
switch (count)
{
- case 0: return { elements.begin() + (pos.raw_ - elements.cbegin()) };
+ case 0: return { elems_.begin() + (pos.raw_ - elems_.cbegin()) };
case 1: return insert(pos, static_cast(val), flags);
default:
{
- const auto start_idx = static_cast(pos.raw_ - elements.cbegin());
+ const auto start_idx = static_cast(pos.raw_ - elems_.cbegin());
preinsertion_resize(start_idx, count);
size_t i = start_idx;
for (size_t e = start_idx + count - 1u; i < e; i++)
- elements[i].reset(impl::make_node(val, flags));
+ elems_[i].reset(impl::make_node(val, flags));
- elements[i].reset(impl::make_node(static_cast(val), flags));
- return { elements.begin() + static_cast(start_idx) };
+ elems_[i].reset(impl::make_node(static_cast(val), flags));
+ return { elems_.begin() + static_cast(start_idx) };
}
}
}
template
- iterator insert(const_iterator pos, Iter first, Iter last, value_flags flags = value_flags::none)
+ iterator insert(const_iterator pos, Iter first, Iter last, value_flags flags = preserve_source_value_flags)
{
const auto distance = std::distance(first, last);
if (distance <= 0)
- return { elements.begin() + (pos.raw_ - elements.cbegin()) };
+ return { elems_.begin() + (pos.raw_ - elems_.cbegin()) };
else
{
auto count = distance;
@@ -5043,9 +5024,9 @@ TOML_NAMESPACE_START
if (!(*it))
count--;
if (!count)
- return { elements.begin() + (pos.raw_ - elements.cbegin()) };
+ return { elems_.begin() + (pos.raw_ - elems_.cbegin()) };
}
- const auto start_idx = static_cast(pos.raw_ - elements.cbegin());
+ const auto start_idx = static_cast(pos.raw_ - elems_.cbegin());
preinsertion_resize(start_idx, static_cast(count));
size_t i = start_idx;
for (auto it = first; it != last; it++)
@@ -5056,18 +5037,18 @@ TOML_NAMESPACE_START
continue;
}
if constexpr (std::is_rvalue_reference_v)
- elements[i++].reset(impl::make_node(std::move(*it), flags));
+ elems_[i++].reset(impl::make_node(std::move(*it), flags));
else
- elements[i++].reset(impl::make_node(*it, flags));
+ elems_[i++].reset(impl::make_node(*it, flags));
}
- return { elements.begin() + static_cast(start_idx) };
+ return { elems_.begin() + static_cast(start_idx) };
}
}
template
iterator insert(const_iterator pos,
std::initializer_list ilist,
- value_flags flags = value_flags::none)
+ value_flags flags = preserve_source_value_flags)
{
return insert(pos, ilist.begin(), ilist.end(), flags);
}
@@ -5079,17 +5060,17 @@ TOML_NAMESPACE_START
static_assert((impl::is_native || impl::is_one_of)&&!impl::is_cvref,
"Emplacement type parameter must be one of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
- return { elements.emplace(pos.raw_, new impl::wrap_node{ static_cast(args)... }) };
+ return { elems_.emplace(pos.raw_, new impl::wrap_node{ static_cast(args)... }) };
}
iterator erase(const_iterator pos) noexcept
{
- return { elements.erase(pos.raw_) };
+ return { elems_.erase(pos.raw_) };
}
iterator erase(const_iterator first, const_iterator last) noexcept
{
- return { elements.erase(first.raw_, last.raw_) };
+ return { elems_.erase(first.raw_, last.raw_) };
}
template
@@ -5099,21 +5080,21 @@ TOML_NAMESPACE_START
"The default element type argument to toml::array::resize may not be toml::node_view.");
if (!new_size)
- elements.clear();
- else if (new_size < elements.size())
- elements.resize(new_size);
- else if (new_size > elements.size())
- insert(cend(), new_size - elements.size(), static_cast(default_init_val));
+ elems_.clear();
+ else if (new_size < elems_.size())
+ elems_.resize(new_size);
+ else if (new_size > elems_.size())
+ insert(cend(), new_size - elems_.size(), static_cast(default_init_val));
}
void truncate(size_t new_size)
{
- if (new_size < elements.size())
- elements.resize(new_size);
+ if (new_size < elems_.size())
+ elems_.resize(new_size);
}
template
- void push_back(ElemType&& val, value_flags flags = value_flags::none)
+ void push_back(ElemType&& val, value_flags flags = preserve_source_value_flags)
{
emplace_back_if_not_empty_view(static_cast(val), flags);
}
@@ -5126,25 +5107,25 @@ TOML_NAMESPACE_START
"Emplacement type parameter must be one of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
auto nde = new impl::wrap_node{ static_cast(args)... };
- elements.emplace_back(nde);
+ elems_.emplace_back(nde);
return *nde;
}
void pop_back() noexcept
{
- elements.pop_back();
+ elems_.pop_back();
}
TOML_NODISCARD
node* get(size_t index) noexcept
{
- return index < elements.size() ? elements[index].get() : nullptr;
+ return index < elems_.size() ? elems_[index].get() : nullptr;
}
TOML_NODISCARD
const node* get(size_t index) const noexcept
{
- return index < elements.size() ? elements[index].get() : nullptr;
+ return index < elems_.size() ? elems_[index].get() : nullptr;
}
template
@@ -5251,10 +5232,7 @@ TOML_DISABLE_WARNINGS;
#include