diff --git a/include/toml++/toml_array.h b/include/toml++/toml_array.h index ac4c2922..71dcb148 100644 --- a/include/toml++/toml_array.h +++ b/include/toml++/toml_array.h @@ -182,7 +182,11 @@ TOML_IMPL_NAMESPACE_START if constexpr (is_one_of) { - return new type{ std::forward(val) }; + return new type{ static_cast(val) }; + } + else if constexpr (is_native && !std::is_same_v, type>) + { + return new value{ static_cast(val) }; } else { @@ -195,16 +199,18 @@ TOML_IMPL_NAMESPACE_START is_native || is_losslessly_convertible_to_native, "Value initializers must be (or be promotable to) one of the TOML value types" ); + + using value_type = native_type_of>; if constexpr (is_wide_string) { #if TOML_WINDOWS_COMPAT - return new value{ narrow(std::forward(val)) }; + return new value{ narrow(static_cast(val)) }; #else static_assert(dependent_false, "Evaluated unreachable branch!"); #endif } else - return new value{ std::forward(val) }; + return new value{ static_cast(val) }; } } @@ -221,13 +227,13 @@ TOML_IMPL_NAMESPACE_START return static_cast(nullptr); } - return std::forward(val).visit([](auto&& concrete) noexcept + return static_cast(val).visit([](auto&& concrete) noexcept { return static_cast(make_node_specialized(std::forward(concrete))); }); } else - return make_node_specialized(std::forward(val)); + return make_node_specialized(static_cast(val)); } template @@ -310,7 +316,7 @@ TOML_NAMESPACE_START template void emplace_back_if_not_empty_view(T&& val) noexcept { - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { if (!val) return; @@ -511,7 +517,7 @@ TOML_NAMESPACE_START template iterator insert(const_iterator pos, ElemType&& val) noexcept { - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { if (!val) return end(); @@ -561,7 +567,7 @@ TOML_NAMESPACE_START template iterator insert(const_iterator pos, size_t count, ElemType&& val) noexcept { - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { if (!val) return end(); @@ -610,7 +616,7 @@ TOML_NAMESPACE_START { auto count = distance; using deref_type = decltype(*first); - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { for (auto it = first; it != last; it++) if (!(*it)) @@ -623,7 +629,7 @@ TOML_NAMESPACE_START size_t i = start_idx; for (auto it = first; it != last; it++) { - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { if (!(*it)) continue; @@ -769,7 +775,7 @@ TOML_NAMESPACE_START void resize(size_t new_size, ElemType&& default_init_val) noexcept { static_assert( - !impl::is_node_view, + !is_node_view, "The default element type argument to toml::array::resize may not be toml::node_view." ); diff --git a/include/toml++/toml_array.hpp b/include/toml++/toml_array.hpp index 33b9eec2..4fc018a0 100644 --- a/include/toml++/toml_array.hpp +++ b/include/toml++/toml_array.hpp @@ -41,7 +41,7 @@ TOML_NAMESPACE_START TOML_EXTERNAL_LINKAGE array::array(const array& other) noexcept - : node{ other } + : node( other ) { elements.reserve(other.elements.size()); for (const auto& elem : other) @@ -54,7 +54,7 @@ TOML_NAMESPACE_START TOML_EXTERNAL_LINKAGE array::array(array&& other) noexcept - : node{ std::move(other) }, + : node( std::move(other) ), elements{ std::move(other.elements) } { #if TOML_LIFETIME_HOOKS diff --git a/include/toml++/toml_common.h b/include/toml++/toml_common.h index a726727b..c45fd792 100644 --- a/include/toml++/toml_common.h +++ b/include/toml++/toml_common.h @@ -528,9 +528,6 @@ TOML_IMPL_NAMESPACE_START template <> struct node_type_getter { static constexpr auto value = node_type::none; }; template inline constexpr node_type node_type_of = node_type_getter>>::value; - - template - inline constexpr bool is_node_view = is_one_of, node_view, node_view>; } TOML_IMPL_NAMESPACE_END @@ -575,6 +572,10 @@ TOML_NAMESPACE_START /// \brief Metafunction for determining if a type is a toml::date_time or toml::value. template inline constexpr bool is_date_time = std::is_same_v>, value>; + + /// \brief Metafunction for determining if a type is a toml::node_view. + template + inline constexpr bool is_node_view = impl::is_one_of, node_view, node_view>; } TOML_NAMESPACE_END diff --git a/include/toml++/toml_date_time.h b/include/toml++/toml_date_time.h index 80770556..8bdfd19e 100644 --- a/include/toml++/toml_date_time.h +++ b/include/toml++/toml_date_time.h @@ -313,7 +313,8 @@ TOML_NAMESPACE_START TOML_NODISCARD_CTOR constexpr date_time() noexcept : date{}, - time{} + time{}, + offset{} // TINAE - icc bugfix {} /// \brief Constructs a local date-time. @@ -323,7 +324,8 @@ TOML_NAMESPACE_START TOML_NODISCARD_CTOR constexpr date_time(toml::date d, toml::time t) noexcept : date{ d }, - time{ t } + time{ t }, + offset{} // TINAE - icc bugfix {} /// \brief Constructs an offset date-time. diff --git a/include/toml++/toml_preprocessor.h b/include/toml++/toml_preprocessor.h index 6f0fcaac..9d7fc920 100644 --- a/include/toml++/toml_preprocessor.h +++ b/include/toml++/toml_preprocessor.h @@ -319,8 +319,9 @@ is no longer necessary. #define TOML_MAY_THROW noexcept #endif -#if TOML_GCC || TOML_CLANG - // fp charconv not in supported any version of gcc or clang as of 26/11/2020 +#if TOML_GCC || TOML_CLANG || (TOML_ICC && !TOML_ICC_CL) + // not supported by any version of GCC or Clang as of 26/11/2020 + // not supported by any version of ICC on Linux as of 11/01/2021 #define TOML_FLOAT_CHARCONV 0 #endif #if defined(__EMSCRIPTEN__) || defined(__APPLE__) diff --git a/include/toml++/toml_table.h b/include/toml++/toml_table.h index 2db13099..ef80bfa7 100644 --- a/include/toml++/toml_table.h +++ b/include/toml++/toml_table.h @@ -502,7 +502,7 @@ TOML_NAMESPACE_START "Insertion using wide-character keys is only supported on Windows with TOML_WINDOWS_COMPAT enabled." ); - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { if (!val) return { end(), false }; @@ -644,7 +644,7 @@ TOML_NAMESPACE_START "Insertion using wide-character keys is only supported on Windows with TOML_WINDOWS_COMPAT enabled." ); - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { if (!val) return { end(), false }; diff --git a/include/toml++/toml_table.hpp b/include/toml++/toml_table.hpp index e79a97bb..6bb3ae8b 100644 --- a/include/toml++/toml_table.hpp +++ b/include/toml++/toml_table.hpp @@ -42,7 +42,7 @@ TOML_NAMESPACE_START TOML_EXTERNAL_LINKAGE table::table(const table& other) noexcept - : node{ std::move(other) }, + : node( other ), inline_{ other.inline_ } { for (auto&& [k, v] : other) @@ -55,7 +55,7 @@ TOML_NAMESPACE_START TOML_EXTERNAL_LINKAGE table::table(table&& other) noexcept - : node{ std::move(other) }, + : node( std::move(other) ), map{ std::move(other.map) }, inline_{ other.inline_ } { diff --git a/include/toml++/toml_value.h b/include/toml++/toml_value.h index bda00c24..65e116dc 100644 --- a/include/toml++/toml_value.h +++ b/include/toml++/toml_value.h @@ -250,7 +250,7 @@ TOML_NAMESPACE_START /// \brief Copy constructor. TOML_NODISCARD_CTOR value(const value& other) noexcept - : node{ other }, + : node( other ), val_{ other.val_ }, flags_{ other.flags_ } { @@ -262,7 +262,7 @@ TOML_NAMESPACE_START /// \brief Move constructor. TOML_NODISCARD_CTOR value(value&& other) noexcept - : node{ std::move(other) }, + : node( std::move(other) ), val_{ std::move(other.val_) }, flags_{ other.flags_ } { diff --git a/toml.hpp b/toml.hpp index be0c8c01..3eabb997 100644 --- a/toml.hpp +++ b/toml.hpp @@ -333,8 +333,9 @@ is no longer necessary. #define TOML_MAY_THROW noexcept #endif -#if TOML_GCC || TOML_CLANG - // fp charconv not in supported any version of gcc or clang as of 26/11/2020 +#if TOML_GCC || TOML_CLANG || (TOML_ICC && !TOML_ICC_CL) + // not supported by any version of GCC or Clang as of 26/11/2020 + // not supported by any version of ICC on Linux as of 11/01/2021 #define TOML_FLOAT_CHARCONV 0 #endif #if defined(__EMSCRIPTEN__) || defined(__APPLE__) @@ -1074,9 +1075,6 @@ TOML_IMPL_NAMESPACE_START template <> struct node_type_getter { static constexpr auto value = node_type::none; }; template inline constexpr node_type node_type_of = node_type_getter>>::value; - - template - inline constexpr bool is_node_view = is_one_of, node_view, node_view>; } TOML_IMPL_NAMESPACE_END @@ -1111,6 +1109,9 @@ TOML_NAMESPACE_START template inline constexpr bool is_date_time = std::is_same_v>, value>; + + template + inline constexpr bool is_node_view = impl::is_one_of, node_view, node_view>; } TOML_NAMESPACE_END @@ -1588,13 +1589,15 @@ TOML_NAMESPACE_START TOML_NODISCARD_CTOR constexpr date_time() noexcept : date{}, - time{} + time{}, + offset{} // TINAE - icc bugfix {} TOML_NODISCARD_CTOR constexpr date_time(toml::date d, toml::time t) noexcept : date{ d }, - time{ t } + time{ t }, + offset{} // TINAE - icc bugfix {} TOML_NODISCARD_CTOR @@ -2809,7 +2812,7 @@ TOML_NAMESPACE_START TOML_NODISCARD_CTOR value(const value& other) noexcept - : node{ other }, + : node( other ), val_{ other.val_ }, flags_{ other.flags_ } { @@ -2820,7 +2823,7 @@ TOML_NAMESPACE_START TOML_NODISCARD_CTOR value(value&& other) noexcept - : node{ std::move(other) }, + : node( std::move(other) ), val_{ std::move(other.val_) }, flags_{ other.flags_ } { @@ -3586,7 +3589,11 @@ TOML_IMPL_NAMESPACE_START if constexpr (is_one_of) { - return new type{ std::forward(val) }; + return new type{ static_cast(val) }; + } + else if constexpr (is_native && !std::is_same_v, type>) + { + return new value{ static_cast(val) }; } else { @@ -3599,16 +3606,18 @@ TOML_IMPL_NAMESPACE_START is_native || is_losslessly_convertible_to_native, "Value initializers must be (or be promotable to) one of the TOML value types" ); + + using value_type = native_type_of>; if constexpr (is_wide_string) { #if TOML_WINDOWS_COMPAT - return new value{ narrow(std::forward(val)) }; + return new value{ narrow(static_cast(val)) }; #else static_assert(dependent_false, "Evaluated unreachable branch!"); #endif } else - return new value{ std::forward(val) }; + return new value{ static_cast(val) }; } } @@ -3625,13 +3634,13 @@ TOML_IMPL_NAMESPACE_START return static_cast(nullptr); } - return std::forward(val).visit([](auto&& concrete) noexcept + return static_cast(val).visit([](auto&& concrete) noexcept { return static_cast(make_node_specialized(std::forward(concrete))); }); } else - return make_node_specialized(std::forward(val)); + return make_node_specialized(static_cast(val)); } template @@ -3660,7 +3669,7 @@ TOML_NAMESPACE_START template void emplace_back_if_not_empty_view(T&& val) noexcept { - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { if (!val) return; @@ -3766,7 +3775,7 @@ TOML_NAMESPACE_START template iterator insert(const_iterator pos, ElemType&& val) noexcept { - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { if (!val) return end(); @@ -3777,7 +3786,7 @@ TOML_NAMESPACE_START template iterator insert(const_iterator pos, size_t count, ElemType&& val) noexcept { - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { if (!val) return end(); @@ -3810,7 +3819,7 @@ TOML_NAMESPACE_START { auto count = distance; using deref_type = decltype(*first); - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { for (auto it = first; it != last; it++) if (!(*it)) @@ -3823,7 +3832,7 @@ TOML_NAMESPACE_START size_t i = start_idx; for (auto it = first; it != last; it++) { - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { if (!(*it)) continue; @@ -3863,7 +3872,7 @@ TOML_NAMESPACE_START void resize(size_t new_size, ElemType&& default_init_val) noexcept { static_assert( - !impl::is_node_view, + !is_node_view, "The default element type argument to toml::array::resize may not be toml::node_view." ); @@ -4278,7 +4287,7 @@ TOML_NAMESPACE_START "Insertion using wide-character keys is only supported on Windows with TOML_WINDOWS_COMPAT enabled." ); - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { if (!val) return { end(), false }; @@ -4329,7 +4338,7 @@ TOML_NAMESPACE_START "Insertion using wide-character keys is only supported on Windows with TOML_WINDOWS_COMPAT enabled." ); - if constexpr (impl::is_node_view) + if constexpr (is_node_view) { if (!val) return { end(), false }; @@ -7683,7 +7692,7 @@ TOML_NAMESPACE_START TOML_EXTERNAL_LINKAGE array::array(const array& other) noexcept - : node{ other } + : node( other ) { elements.reserve(other.elements.size()); for (const auto& elem : other) @@ -7696,7 +7705,7 @@ TOML_NAMESPACE_START TOML_EXTERNAL_LINKAGE array::array(array&& other) noexcept - : node{ std::move(other) }, + : node( std::move(other) ), elements{ std::move(other.elements) } { #if TOML_LIFETIME_HOOKS @@ -8030,7 +8039,7 @@ TOML_NAMESPACE_START TOML_EXTERNAL_LINKAGE table::table(const table& other) noexcept - : node{ std::move(other) }, + : node( other ), inline_{ other.inline_ } { for (auto&& [k, v] : other) @@ -8043,7 +8052,7 @@ TOML_NAMESPACE_START TOML_EXTERNAL_LINKAGE table::table(table&& other) noexcept - : node{ std::move(other) }, + : node( std::move(other) ), map{ std::move(other.map) }, inline_{ other.inline_ } {