diff --git a/cpp.hint b/cpp.hint index e9277f9e..0a481ffe 100644 --- a/cpp.hint +++ b/cpp.hint @@ -5,13 +5,13 @@ #define TOML_TRIVIAL_ABI #define TOML_ABSTRACT_BASE #define TOML_EMPTY_BASES -#define TOML_MAY_THROW #define TOML_CONSTRAINED_TEMPLATE(cond, ...) template <__VA_ARGS__> #define TOML_LIKELY(...) (__VA_ARGS__) #define TOML_UNLIKELY(...) (__VA_ARGS__) #define TOML_NODISCARD #define TOML_NODISCARD_CTOR #define TOML_RETURNS_BY_THROWING +#define TOML_EXTERN_NOEXCEPT(...) #define TOML_EXTERNAL_LINKAGE #define TOML_INTERNAL_LINKAGE static #define TOML_ANON_NAMESPACE_START namespace diff --git a/docs/pages/main_page.dox b/docs/pages/main_page.dox index 24b19094..9811c2f7 100644 --- a/docs/pages/main_page.dox +++ b/docs/pages/main_page.dox @@ -303,18 +303,18 @@ int main() { - auto tbl = toml::table{{ + auto tbl = toml::table{ { "lib", "toml++" }, { "cpp", toml::array{ 17, 20, "and beyond" } }, { "toml", toml::array{ "1.0.0", "and beyond" } }, { "repo", "https://github.com/marzer/tomlplusplus/" }, - { "author", toml::table{{ + { "author", toml::table{ { "name", "Mark Gillard" }, { "github", "https://github.com/marzer" }, { "twitter", "https://twitter.com/marzer8789" } - }} + } }, - }}; + }; // serializing as TOML std::cout << "###### TOML ######" << "\n\n"; diff --git a/include/toml++/impl/array.h b/include/toml++/impl/array.h index d27913f8..68ccc870 100644 --- a/include/toml++/impl/array.h +++ b/include/toml++/impl/array.h @@ -6,6 +6,7 @@ #include "value.h" #include "std_vector.h" +#include "std_initializer_list.h" #include "make_node.h" #include "header_start.h" @@ -13,10 +14,10 @@ TOML_IMPL_NAMESPACE_START { template - class TOML_TRIVIAL_ABI array_iterator final + class TOML_TRIVIAL_ABI array_iterator { private: - template + template friend class array_iterator; friend class TOML_NAMESPACE::array; @@ -251,10 +252,10 @@ TOML_NAMESPACE_START std::vector> elements; TOML_API - void preinsertion_resize(size_t idx, size_t count) noexcept; + void preinsertion_resize(size_t idx, size_t count); template - void emplace_back_if_not_empty_view(T&& val) noexcept + void emplace_back_if_not_empty_view(T&& val) { if constexpr (is_node_view) { @@ -308,7 +309,7 @@ TOML_NAMESPACE_START /// \brief Copy constructor. TOML_NODISCARD_CTOR TOML_API - array(const array&) noexcept; + array(const array&); /// \brief Move constructor. TOML_NODISCARD_CTOR @@ -317,7 +318,7 @@ TOML_NAMESPACE_START /// \brief Copy-assignment operator. TOML_API - array& operator=(const array&) noexcept; + array& operator=(const array&); /// \brief Move-assignment operator. TOML_API @@ -356,7 +357,7 @@ TOML_NAMESPACE_START /// \tparam ElemTypes One of the TOML node or value types (or a type promotable to one). /// \param val The node or value used to initialize element 0. /// \param vals The nodes or values used to initialize elements 1...N. - TOML_CONSTRAINED_TEMPLATE((sizeof...(ElemTypes) > 0 || !std::is_same_v, array>), + TOML_CONSTRAINED_TEMPLATE((sizeof...(ElemTypes) > 0 || !std::is_same_v, array>), typename ElemType, typename... ElemTypes) TOML_NODISCARD_CTOR @@ -594,7 +595,7 @@ 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) noexcept + iterator insert(const_iterator pos, ElemType&& val) { if constexpr (is_node_view) { @@ -642,7 +643,7 @@ 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) noexcept + iterator insert(const_iterator pos, size_t count, ElemType&& val) { if constexpr (is_node_view) { @@ -682,7 +683,7 @@ 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) noexcept + iterator insert(const_iterator pos, Iter first, Iter last) { const auto distance = std::distance(first, last); if (distance <= 0) @@ -732,7 +733,7 @@ TOML_NAMESPACE_START /// \conditional_return{All objects in the list were empty toml::node_views} /// A copy of pos template - iterator insert(const_iterator pos, std::initializer_list ilist) noexcept + iterator insert(const_iterator pos, std::initializer_list ilist) { return insert(pos, ilist.begin(), ilist.end()); } @@ -762,7 +763,7 @@ TOML_NAMESPACE_START /// \remarks There is no difference between insert() and emplace() /// for trivial value types (floats, ints, bools). template - iterator emplace(const_iterator pos, Args&&... args) noexcept + iterator emplace(const_iterator pos, Args&&... args) { using type = impl::unwrap_node; static_assert((impl::is_native || impl::is_one_of)&&!impl::is_cvref, @@ -848,7 +849,7 @@ TOML_NAMESPACE_START /// \param new_size The number of elements the array will have after resizing. /// \param default_init_val The node or value used to initialize new elements if the array needs to grow. template - void resize(size_t new_size, ElemType&& default_init_val) noexcept + void resize(size_t new_size, ElemType&& default_init_val) { static_assert(!is_node_view, "The default element type argument to toml::array::resize may not be toml::node_view."); @@ -911,7 +912,7 @@ TOML_NAMESPACE_START /// \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) noexcept + void push_back(ElemType&& val) { emplace_back_if_not_empty_view(static_cast(val)); } @@ -938,7 +939,7 @@ TOML_NAMESPACE_START /// \remarks There is no difference between push_back() and emplace_back() /// For trivial value types (floats, ints, bools). template - decltype(auto) emplace_back(Args&&... args) noexcept + decltype(auto) emplace_back(Args&&... args) { using type = impl::unwrap_node; static_assert((impl::is_native || impl::is_one_of)&&!impl::is_cvref, diff --git a/include/toml++/impl/array.inl b/include/toml++/impl/array.inl index 0de65d79..8766dce5 100644 --- a/include/toml++/impl/array.inl +++ b/include/toml++/impl/array.inl @@ -43,7 +43,7 @@ TOML_ANON_NAMESPACE_END; TOML_NAMESPACE_START { TOML_EXTERNAL_LINKAGE - array::array(const array& other) noexcept // + array::array(const array& other) // : node(other) { elements.reserve(other.elements.size()); @@ -66,7 +66,7 @@ TOML_NAMESPACE_START } TOML_EXTERNAL_LINKAGE - array& array::operator=(const array& rhs) noexcept + array& array::operator=(const array& rhs) { if (&rhs != this) { @@ -91,7 +91,7 @@ TOML_NAMESPACE_START } TOML_EXTERNAL_LINKAGE - void array::preinsertion_resize(size_t idx, size_t count) noexcept + void array::preinsertion_resize(size_t idx, size_t count) { TOML_ASSERT(idx <= elements.size()); TOML_ASSERT(count >= 1u); diff --git a/include/toml++/impl/default_formatter.h b/include/toml++/impl/default_formatter.h index 3ccd6b97..392b295a 100644 --- a/include/toml++/impl/default_formatter.h +++ b/include/toml++/impl/default_formatter.h @@ -16,12 +16,12 @@ TOML_NAMESPACE_START /// operators of the TOML node types already print themselves out using this formatter. /// /// \detail \cpp - /// auto tbl = toml::table{{ + /// auto tbl = toml::table{ /// { "description", "This is some TOML, yo." }, /// { "fruit", toml::array{ "apple", "orange", "pear" } }, /// { "numbers", toml::array{ 1, 2, 3, 4, 5 } }, - /// { "table", toml::table{{ { "foo", "bar" } }} } - /// }}; + /// { "table", toml::table{ { "foo", "bar" } } } + /// }; /// /// // these two lines are equivalent: /// std::cout << toml::default_formatter{ tbl } << "\n"; diff --git a/include/toml++/impl/forward_declarations.h b/include/toml++/impl/forward_declarations.h index 0d116539..eae6adc5 100644 --- a/include/toml++/impl/forward_declarations.h +++ b/include/toml++/impl/forward_declarations.h @@ -335,7 +335,7 @@ TOML_NAMESPACE_END; TOML_IMPL_NAMESPACE_START { template - using remove_cvref_t = std::remove_cv_t>; + using remove_cvref = std::remove_cv_t>; template inline constexpr bool is_one_of = (false || ... || std::is_same_v); @@ -347,6 +347,14 @@ TOML_IMPL_NAMESPACE_START inline constexpr bool is_wide_string = is_one_of, const wchar_t*, wchar_t*, std::wstring_view, std::wstring>; + template + static constexpr bool value_retrieval_is_nothrow = !std::is_same_v, std::string> +#if TOML_HAS_CHAR8 + && !std::is_same_v, std::u8string> +#endif + + && !is_wide_string; + template inline constexpr bool dependent_false = false; @@ -767,7 +775,7 @@ TOML_IMPL_NAMESPACE_START static constexpr auto value = node_type::none; }; template - inline constexpr node_type node_type_of = node_type_getter>>::value; + inline constexpr node_type node_type_of = node_type_getter>>::value; } TOML_IMPL_NAMESPACE_END; /// \endcond @@ -776,11 +784,11 @@ TOML_NAMESPACE_START { /// \brief Metafunction for determining if a type is, or is a reference to, a toml::table. template - inline constexpr bool is_table = std::is_same_v, table>; + inline constexpr bool is_table = std::is_same_v, table>; /// \brief Metafunction for determining if a type is, or is a reference to, a toml::array. template - inline constexpr bool is_array = std::is_same_v, array>; + inline constexpr bool is_array = std::is_same_v, array>; /// \brief Metafunction for determining if a type satisfies either toml::is_table or toml::is_array. template @@ -788,15 +796,15 @@ TOML_NAMESPACE_START /// \brief Metafunction for determining if a type is, or is a reference to, a std::string or toml::value. template - inline constexpr bool is_string = std::is_same_v>, value>; + inline constexpr bool is_string = std::is_same_v>, value>; /// \brief Metafunction for determining if a type is, or is a reference to, a int64_t or toml::value. template - inline constexpr bool is_integer = std::is_same_v>, value>; + inline constexpr bool is_integer = std::is_same_v>, value>; /// \brief Metafunction for determining if a type is, or is a reference to, a double or toml::value. template - inline constexpr bool is_floating_point = std::is_same_v>, value>; + inline constexpr bool is_floating_point = std::is_same_v>, value>; /// \brief Metafunction for determining if a type satisfies either toml::is_integer or toml::is_floating_point. template @@ -804,19 +812,19 @@ TOML_NAMESPACE_START /// \brief Metafunction for determining if a type is, or is a reference to, a bool or toml::value. template - inline constexpr bool is_boolean = std::is_same_v>, value>; + inline constexpr bool is_boolean = std::is_same_v>, value>; /// \brief Metafunction for determining if a type is, or is a reference to, a toml::date or toml::value. template - inline constexpr bool is_date = std::is_same_v>, value>; + inline constexpr bool is_date = std::is_same_v>, value>; /// \brief Metafunction for determining if a type is, or is a reference to, a toml::time or toml::value