diff --git a/.circleci/config.yml b/.circleci/config.yml index 3065e0a..871dac4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,40 +2,6 @@ version: 2 jobs: - debug_clang9_dox: - docker: - - image: marzer/misc_cpp17_dev:latest - steps: - - checkout - - run: - name: Initializing locales - command: | - sudo apt-get update && sudo apt-get install -y locales - sudo locale-gen 'en_US.utf8' 'ja_JP.utf8' 'de_DE.utf8' 'it_IT.utf8' 'tr_TR.utf8' 'fi_FI.utf8' 'fr_FR.utf8' 'zh_CN.utf8' - - run: - name: Checking toml.hpp - command: | - cd python && python3 ci_single_header_check.py - - run: - name: Pulling submodules - command: | - git submodule update --init extern/Catch2 - git submodule update --init extern/tloptional - - run: - name: Building and testing with clang 9 - command: | - CXX=clang++-9 meson build --buildtype=debug -DGENERATE_CMAKE_CONFIG=disabled -DBUILD_EXAMPLES=disabled - cd build && ninja -v -j 4 && ninja test - - run: - name: Generating documentation - command: | - git submodule update --init extern/mcss - cd python && python3 generate_documentation.py - - persist_to_workspace: - root: docs - paths: html - - debug_clang9: docker: - image: marzer/misc_cpp17_dev:latest @@ -61,7 +27,6 @@ jobs: CXX=clang++-9 meson build --buildtype=debug -DGENERATE_CMAKE_CONFIG=disabled -DBUILD_EXAMPLES=disabled cd build && ninja -v -j 4 && ninja test - release_clang9: docker: - image: marzer/misc_cpp17_dev:latest @@ -87,7 +52,6 @@ jobs: CXX=clang++-9 meson build --buildtype=release -DGENERATE_CMAKE_CONFIG=disabled -DBUILD_EXAMPLES=disabled cd build && ninja -v -j 4 && ninja test - debug_gcc9: docker: - image: marzer/misc_cpp17_dev:latest @@ -109,7 +73,6 @@ jobs: CXX=g++-9 meson build --buildtype=debug -DGENERATE_CMAKE_CONFIG=disabled -DBUILD_EXAMPLES=disabled cd build && ninja -v -j 4 && ninja test - release_gcc9: docker: - image: marzer/misc_cpp17_dev:latest @@ -131,6 +94,22 @@ jobs: CXX=g++-9 meson build --buildtype=release -DGENERATE_CMAKE_CONFIG=disabled -DBUILD_EXAMPLES=disabled cd build && ninja -v -j 4 && ninja test + generate_dox: + docker: + - image: marzer/misc_cpp17_dev:latest + steps: + - checkout + - run: + name: Pulling submodules + command: | + git submodule update --init extern/mcss + - run: + name: Generating documentation + command: | + cd python && python3 generate_documentation.py + - persist_to_workspace: + root: docs + paths: html deploy_dox: docker: @@ -156,25 +135,23 @@ jobs: name: Deploy docs to gh-pages branch command: gh-pages --dotfiles --message "[skip ci] Updates" --dist docs/html - workflows: version: 2 build: jobs: - - debug_clang9_dox: - filters: - branches: - only: master - - debug_clang9: - filters: - branches: - ignore: master + - debug_clang9 - release_clang9 - debug_gcc9 - release_gcc9 - - deploy_dox: + - generate_dox: requires: - - debug_clang9_dox + - debug_clang9 - release_clang9 - debug_gcc9 - release_gcc9 + filters: + branches: + only: master + - deploy_dox: + requires: + - generate_dox diff --git a/README.md b/README.md index 08c09f4..9c35c64 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,6 @@ won't need to mess with these at all, but if you do, set them before including t | `TOML_ALL_INLINE` | boolean | `1` | Disable this to explicitly control where toml++'s implementation is compiled (e.g. as part of a library). | | `TOML_API` | define | undefined | API annotation to add to public symbols (e.g. `__declspec(dllexport)` on Windows). | | `TOML_ASSERT(expr)` | function macro | `assert(expr)`
(or undefined) | Sets the assert function used by the library. | -| `TOML_CHAR_8_STRINGS` | boolean | `0` | Uses C++20 [char8_t]-based strings as the toml string data type. **_Experimental!_** | | `TOML_CONFIG_HEADER` | string literal | undefined | Includes the given header file before the rest of the library. | | `TOML_EXCEPTIONS` | boolean | per your compiler's settings | Sets whether the library uses exceptions. | | `TOML_IMPLEMENTATION` | define | undefined | Define this to enable compilation of the library's implementation. Meaningless if `TOML_ALL_INLINE` is `1`. | @@ -187,6 +186,7 @@ UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's '[ - **[@okureta](https://github.com/okureta)** - Reported a bug - **[@prince-chrismc](https://github.com/prince-chrismc)** - Added toml++ to ConanCenter, and fixed some typos - **[@rbrugo](https://github.com/rbrugo)** - Helped design a new feature +- **[@Reedbeta](https://github.com/Reedbeta)** - Added additional Visual Studio debugger native visualizers - **[@shdnx](https://github.com/shdnx)** - Fixed a bug on GCC 8.2.0 and some meson config issues - **[@traversaro](https://github.com/traversaro)** - Added vcpkg support and reported a bunch of bugs - **[@ximion](https://github.com/ximion)** - Added support for installation with meson diff --git a/docs/Doxyfile b/docs/Doxyfile index db7182c..b3d84e1 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -327,9 +327,9 @@ PREDEFINED = DOXYGEN=1 \ TOML_PUSH_WARNINGS= \ TOML_DISABLE_SWITCH_WARNINGS= \ TOML_DISABLE_INIT_WARNINGS= \ - TOML_DISABLE_VTABLE_WARNINGS= \ + TOML_DISABLE_MISC_WARNINGS= \ TOML_DISABLE_PADDING_WARNINGS= \ - TOML_DISABLE_FLOAT_WARNINGS= \ + TOML_DISABLE_ARITHMETIC_WARNINGS= \ TOML_DISABLE_SHADOW_WARNINGS= \ TOML_DISABLE_SUGGEST_WARNINGS= \ TOML_DISABLE_ALL_WARNINGS= \ diff --git a/examples/utf8_console.h b/examples/utf8_console.h index 602d724..2ac7ee4 100644 --- a/examples/utf8_console.h +++ b/examples/utf8_console.h @@ -3,20 +3,16 @@ //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT +#include #ifdef _WIN32 - - #include - - inline void init_utf8_console() noexcept - { - SetConsoleOutputCP(65001); //CP_UTF8 - } - -#else - - inline void init_utf8_console() noexcept - { - // no-op - } - +#include #endif + + inline void init_utf8_console() noexcept + { + #ifdef _WIN32 + SetConsoleOutputCP(65001); //CP_UTF8 + #endif + + std::cout << std::boolalpha; + } diff --git a/include/toml++/toml.h b/include/toml++/toml.h index 409a994..c27fbcd 100644 --- a/include/toml++/toml.h +++ b/include/toml++/toml.h @@ -39,6 +39,7 @@ #include "toml_default_formatter.hpp" #include "toml_json_formatter.hpp" #if TOML_PARSER + #include "toml_utf8_streams.hpp" #include "toml_parser.hpp" #endif // TOML_PARSER @@ -56,9 +57,9 @@ #undef TOML_PUSH_WARNINGS #undef TOML_DISABLE_SWITCH_WARNINGS #undef TOML_DISABLE_INIT_WARNINGS - #undef TOML_DISABLE_VTABLE_WARNINGS + #undef TOML_DISABLE_MISC_WARNINGS #undef TOML_DISABLE_PADDING_WARNINGS - #undef TOML_DISABLE_FLOAT_WARNINGS + #undef TOML_DISABLE_ARITHMETIC_WARNINGS #undef TOML_DISABLE_SHADOW_WARNINGS #undef TOML_DISABLE_SUGGEST_WARNINGS #undef TOML_DISABLE_ALL_WARNINGS @@ -81,7 +82,6 @@ #undef TOML_LANG_HIGHER_THAN #undef TOML_LANG_AT_LEAST #undef TOML_LANG_UNRELEASED - #undef TOML_STRING_PREFIX #undef TOML_UNDEF_MACROS #undef TOML_RELOPS_REORDERING #undef TOML_ASYMMETRICAL_EQUALITY_OPS @@ -89,11 +89,13 @@ #undef TOML_IMPLEMENTATION #undef TOML_EXTERNAL_LINKAGE #undef TOML_INTERNAL_LINKAGE - #undef TOML_INTERNAL_NAMESPACE + #undef TOML_ANONYMOUS_NAMESPACE + #undef TOML_ANONYMOUS_NAMESPACE_END #undef TOML_COMPILER_EXCEPTIONS #undef TOML_TRIVIAL_ABI #undef TOML_ABI_NAMESPACES #undef TOML_ABI_NAMESPACE_START + #undef TOML_ABI_NAMESPACE_VERSION #undef TOML_ABI_NAMESPACE_BOOL #undef TOML_ABI_NAMESPACE_END #undef TOML_PARSER_TYPENAME @@ -105,8 +107,9 @@ #undef TOML_HAS_CUSTOM_OPTIONAL_TYPE #undef TOML_UNWRAPPED_NODE_TYPE_LIST #undef TOML_NATIVE_VALUE_TYPE_LIST - #undef TOML_NATIVE_STRING_TYPE_NAME #undef TOML_NODE_TYPE_LIST + #undef TOML_IMPL_NAMESPACE_START + #undef TOML_IMPL_NAMESPACE_END #endif //# {{ diff --git a/include/toml++/toml_array.h b/include/toml++/toml_array.h index 2d8c7a6..7d17b91 100644 --- a/include/toml++/toml_array.h +++ b/include/toml++/toml_array.h @@ -7,10 +7,12 @@ #include "toml_value.h" TOML_PUSH_WARNINGS -TOML_DISABLE_VTABLE_WARNINGS +TOML_DISABLE_MISC_WARNINGS -namespace toml::impl +namespace toml { + TOML_IMPL_NAMESPACE_START + template class TOML_TRIVIAL_ABI array_iterator final { @@ -20,7 +22,7 @@ namespace toml::impl using raw_mutable_iterator = std::vector>::iterator; using raw_const_iterator = std::vector>::const_iterator; using raw_iterator = std::conditional_t; - + mutable raw_iterator raw_; array_iterator(raw_mutable_iterator raw) noexcept @@ -160,12 +162,17 @@ namespace toml::impl return *(raw_ + idx)->get(); } + TOML_PUSH_WARNINGS + TOML_DISABLE_ALL_WARNINGS + template > [[nodiscard]] operator array_iterator() const noexcept { return array_iterator{ raw_ }; } + + TOML_POP_WARNINGS }; template @@ -187,7 +194,8 @@ namespace toml::impl { static_assert( !is_wide_string || TOML_WINDOWS_COMPAT, - "Instantiating values from wide-character strings is only supported on Windows with TOML_WINDOWS_COMPAT enabled." + "Instantiating values from wide-character strings is only " + "supported on Windows with TOML_WINDOWS_COMPAT enabled." ); static_assert( is_native || is_losslessly_convertible_to_native, @@ -214,10 +222,14 @@ namespace toml::impl { return make_node(std::move(val.value)); } + + TOML_IMPL_NAMESPACE_END } namespace toml { + TOML_ABI_NAMESPACE_VERSION + [[nodiscard]] TOML_API bool operator == (const array& lhs, const array& rhs) noexcept; [[nodiscard]] TOML_API bool operator != (const array& lhs, const array& rhs) noexcept; template @@ -363,6 +375,33 @@ namespace toml [[nodiscard]] array* as_array() noexcept override; [[nodiscard]] const array* as_array() const noexcept override; + /// \brief Checks if the array contains nodes of only one type. + /// + /// \detail \cpp + /// auto arr = toml::array{ 1, 2, 3 }; + /// std::cout << "homogenous: "sv << arr.is_homogeneous(toml::node_type::none) << std::endl; + /// std::cout << "all floats: "sv << arr.is_homogeneous(toml::node_type::floating_point) << std::endl; + /// std::cout << "all arrays: "sv << arr.is_homogeneous(toml::node_type::array) << std::endl; + /// std::cout << "all integers: "sv << arr.is_homogeneous(toml::node_type::integer) << std::endl; + /// + /// \ecpp + /// + /// \out + /// homogeneous: true + /// all doubles: false + /// all arrays: false + /// all integers: true + /// \eout + /// + /// \param type A TOML node type.
+ /// `toml::node_type::none`: "is every node the same type?" + /// Anything else: "is every node one of these?"
+ /// + /// \returns True if the array was homogeneous. + /// + /// \remarks Always returns `false` for empty arrays. + [[nodiscard]] bool is_homogeneous(node_type type) const noexcept; + /// \brief Checks if the array contains nodes of only one type. /// /// \detail \cpp @@ -382,40 +421,32 @@ namespace toml /// \eout /// /// \tparam T A TOML node type.
- /// Explicitly specified: "is every node a T?"
/// Left as `void`: "is every node the same type?" + /// Explicitly specified: "is every node a T?"
/// /// \returns True if the array was homogeneous. /// /// \remarks Always returns `false` for empty arrays. template - [[nodiscard]] bool is_homogeneous() const noexcept + [[nodiscard]] + bool is_homogeneous() const noexcept { - if (values.empty()) - return false; - - if constexpr (std::is_same_v) - { - const auto type = values[0]->type(); - for (size_t i = 1; i < values.size(); i++) - if (values[i]->type() != type) - return false; - } + using type = impl::unwrap_node; + static_assert( + std::is_void_v + || ((impl::is_native || impl::is_one_of) && !impl::is_cvref), + "The template type argument of array::is_homogeneous() must be void or one of the following:" + TOML_UNWRAPPED_NODE_TYPE_LIST + ); + + if constexpr (std::is_void_v) + return is_homogeneous(node_type::none); else - { - for (auto& v : values) - if (!v->is()) - return false; - } - return true; + return is_homogeneous(impl::node_type_of); } /// \brief Returns true if this array contains only tables. - [[nodiscard]] TOML_ALWAYS_INLINE - bool is_array_of_tables() const noexcept override - { - return is_homogeneous(); - } + [[nodiscard]] bool is_array_of_tables() const noexcept override; /// \brief Gets a reference to the node at a specific index. [[nodiscard]] node& operator[] (size_t index) noexcept; @@ -619,7 +650,7 @@ namespace toml { using type = impl::unwrap_node; static_assert( - impl::is_native || impl::is_one_of, + (impl::is_native || impl::is_one_of) && !impl::is_cvref, "Emplacement type parameter must be one of the following:" TOML_UNWRAPPED_NODE_TYPE_LIST ); @@ -781,7 +812,7 @@ namespace toml { using type = impl::unwrap_node; static_assert( - impl::is_native || impl::is_one_of, + (impl::is_native || impl::is_one_of) && !impl::is_cvref, "Emplacement type parameter must be one of the following:" TOML_UNWRAPPED_NODE_TYPE_LIST ); @@ -843,7 +874,8 @@ namespace toml /// /// \returns A pointer to the selected node if it existed and was of the specified type, or nullptr. template - [[nodiscard]] impl::wrap_node* get_as(size_t index) noexcept + [[nodiscard]] + impl::wrap_node* get_as(size_t index) noexcept { if (auto val = get(index)) return val->as(); @@ -857,7 +889,8 @@ namespace toml /// /// \returns A pointer to the selected node if it existed and was of the specified type, or nullptr. template - [[nodiscard]] const impl::wrap_node* get_as(size_t index) const noexcept + [[nodiscard]] + const impl::wrap_node* get_as(size_t index) const noexcept { if (auto val = get(index)) return val->as(); @@ -883,7 +916,8 @@ namespace toml private: template - [[nodiscard]] static bool container_equality(const array& lhs, const T& rhs) noexcept + [[nodiscard]] + static bool container_equality(const array& lhs, const T& rhs) noexcept { using element_type = std::remove_const_t; static_assert( @@ -915,7 +949,8 @@ namespace toml /// \brief Initializer list equality operator. template - [[nodiscard]] friend bool operator == (const array& lhs, const std::initializer_list& rhs) noexcept + [[nodiscard]] + friend bool operator == (const array& lhs, const std::initializer_list& rhs) noexcept { return container_equality(lhs, rhs); } @@ -923,7 +958,8 @@ namespace toml /// \brief Vector equality operator. template - [[nodiscard]] friend bool operator == (const array& lhs, const std::vector& rhs) noexcept + [[nodiscard]] + friend bool operator == (const array& lhs, const std::vector& rhs) noexcept { return container_equality(lhs, rhs); } @@ -952,7 +988,7 @@ namespace toml array& flatten() &; /// \brief Flattens this array, recursively hoisting the contents of child arrays up into itself (rvalue overload). - array&& flatten()&& + array&& flatten() && { return static_cast(static_cast(*this).flatten()); } @@ -961,6 +997,8 @@ namespace toml template friend std::basic_ostream& operator << (std::basic_ostream&, const array&); }; + + TOML_ABI_NAMESPACE_END // version } -TOML_POP_WARNINGS //TOML_DISABLE_VTABLE_WARNINGS +TOML_POP_WARNINGS //TOML_DISABLE_MISC_WARNINGS diff --git a/include/toml++/toml_array.hpp b/include/toml++/toml_array.hpp index 411f28d..1b3d008 100644 --- a/include/toml++/toml_array.hpp +++ b/include/toml++/toml_array.hpp @@ -18,6 +18,8 @@ TOML_DISABLE_SUGGEST_WARNINGS namespace toml { + TOML_ABI_NAMESPACE_VERSION + TOML_EXTERNAL_LINKAGE void array::preinsertion_resize(size_t idx, size_t count) noexcept { @@ -232,6 +234,30 @@ namespace toml return *this; } + + TOML_EXTERNAL_LINKAGE + bool array::is_homogeneous(node_type type) const noexcept + { + if (values.empty()) + return false; + + if (type == node_type::none) + type = values[0]->type(); + + for (const auto& val : values) + if (val->type() != type) + return false; + + return true; + } + + TOML_EXTERNAL_LINKAGE + bool array::is_array_of_tables() const noexcept + { + return is_homogeneous(node_type::table); + } + + TOML_ABI_NAMESPACE_END // version } TOML_POP_WARNINGS // TOML_DISABLE_SUGGEST_WARNINGS diff --git a/include/toml++/toml_common.h b/include/toml++/toml_common.h index 25f4463..11bd908 100644 --- a/include/toml++/toml_common.h +++ b/include/toml++/toml_common.h @@ -31,10 +31,6 @@ TOML_DISABLE_ALL_WARNINGS TOML_POP_WARNINGS -#if TOML_CHAR_8_STRINGS && !defined(__cpp_lib_char8_t) - #error toml++ requires implementation support to use char8_t strings, but yours does not provide it. -#endif - #ifdef __cpp_lib_launder #define TOML_LAUNDER(x) std::launder(x) #else @@ -59,8 +55,27 @@ TOML_DISABLE_PADDING_WARNINGS TOML_DISABLE_SHADOW_WARNINGS /// \brief The root namespace for all toml++ functions and types. +namespace toml { TOML_ABI_NAMESPACE_VERSION TOML_ABI_NAMESPACE_END } + +#if TOML_WINDOWS_COMPAT namespace toml { + TOML_IMPL_NAMESPACE_START + + [[nodiscard]] TOML_API std::string narrow(std::wstring_view) noexcept; + [[nodiscard]] TOML_API std::wstring widen(std::string_view) noexcept; + #ifdef __cpp_lib_char8_t + [[nodiscard]] TOML_API std::wstring widen(std::u8string_view) noexcept; + #endif + + TOML_IMPL_NAMESPACE_END +} +#endif // TOML_WINDOWS_COMPAT + +namespace toml +{ + TOML_ABI_NAMESPACE_VERSION + using namespace std::string_literals; using namespace std::string_view_literals; using size_t = std::size_t; @@ -74,53 +89,11 @@ namespace toml return static_cast(n); } - #if TOML_CHAR_8_STRINGS - - using string_char = char8_t; - using string = std::u8string; - using string_view = std::u8string_view; - - #else - - /// \brief The base character type for keys and string values. - /// \remarks This will be an alias for char8_t if #TOML_CHAR_8_STRINGS is enabled. + // legacy typedefs using string_char = char; - - /// \brief The string type for keys and string values. - /// \remarks This will be an alias for std::u8string if #TOML_CHAR_8_STRINGS is enabled. using string = std::string; - - /// \brief The string type for keys and string values. - /// \remarks This will be an alias for std::u8string_view if #TOML_CHAR_8_STRINGS is enabled. using string_view = std::string_view; - #endif - - #if TOML_WINDOWS_COMPAT - namespace impl - { - [[nodiscard]] TOML_API std::string narrow_char(std::wstring_view) noexcept; - #ifdef __cpp_lib_char8_t - [[nodiscard]] TOML_API std::u8string narrow_char8(std::wstring_view) noexcept; - #endif - template - [[nodiscard]] auto narrow(std::wstring_view str) noexcept - { - #ifdef __cpp_lib_char8_t - if constexpr (std::is_same_v) - return narrow_char8(str); - else - #endif - return narrow_char(str); - } - - [[nodiscard]] TOML_API std::wstring widen(std::string_view) noexcept; - #ifdef __cpp_lib_char8_t - [[nodiscard]] TOML_API std::wstring widen(std::u8string_view) noexcept; - #endif - } - #endif - #if !TOML_DOXYGEN // foward declarations are hidden from doxygen @@ -150,7 +123,7 @@ namespace toml none, ///< Not-a-node. table, ///< The node is a toml::table. array, ///< The node is a toml::array. - string, ///< The node is a toml::value. + string, ///< The node is a toml::value. integer, ///< The node is a toml::value. floating_point, ///< The node is a toml::value. boolean, ///< The node is a toml::value. @@ -175,23 +148,19 @@ namespace toml #endif - #if TOML_LARGE_FILES - - using source_index = uint32_t; - - #else - - /// \brief The integer type used to tally line numbers and columns. - /// \remarks This will be an alias for uint32_t if #TOML_LARGE_FILES is enabled. - using source_index = uint16_t; - - #endif - /// \brief A pointer to a shared string resource containing a source path. using source_path_ptr = std::shared_ptr; TOML_ABI_NAMESPACE_BOOL(TOML_LARGE_FILES, lf, sf) + #if TOML_LARGE_FILES + using source_index = uint32_t; + #else + /// \brief The integer type used to tally line numbers and columns. + /// \remarks This will be an alias for uint32_t if #TOML_LARGE_FILES is enabled. + using source_index = uint16_t; + #endif + /// \brief A source document line-and-column pair. /// /// \detail \cpp @@ -325,12 +294,17 @@ namespace toml }; TOML_ABI_NAMESPACE_END // TOML_LARGE_FILES -} -namespace toml::impl + TOML_ABI_NAMESPACE_END // version + +} // toml + +namespace toml { + TOML_IMPL_NAMESPACE_START + template - using string_map = std::map>; //heterogeneous lookup + using string_map = std::map>; // heterogeneous lookup template using remove_cvref_t = std::remove_cv_t>; @@ -343,6 +317,9 @@ namespace toml::impl template inline constexpr bool is_one_of = is_one_of_::value; + template + inline constexpr bool is_cvref = std::is_reference_v || std::is_const_v || std::is_volatile_v; + template [[nodiscard]] TOML_ATTR(const) @@ -389,11 +366,11 @@ namespace toml::impl #if TOML_ABI_NAMESPACES #if TOML_EXCEPTIONS - TOML_ABI_NAMESPACE_START(impl_ex) - #define TOML_PARSER_TYPENAME ::toml::impl::abi_impl_ex::parser + TOML_ABI_NAMESPACE_START(ex) + #define TOML_PARSER_TYPENAME ::toml::impl::ex::parser #else - TOML_ABI_NAMESPACE_START(impl_noex) - #define TOML_PARSER_TYPENAME ::toml::impl::abi_impl_noex::parser + TOML_ABI_NAMESPACE_START(noex) + #define TOML_PARSER_TYPENAME ::toml::impl::noex::parser #endif #else #define TOML_PARSER_TYPENAME ::toml::impl::parser @@ -461,7 +438,6 @@ namespace toml::impl template struct integer_value_traits : unsigned_integer_value_traits {}; - template <> struct value_traits : integer_value_traits {}; template <> struct value_traits : integer_value_traits {}; template <> struct value_traits : integer_value_traits {}; template <> struct value_traits : integer_value_traits {}; @@ -479,7 +455,7 @@ namespace toml::impl using native_type = int64_t; static constexpr bool is_native = false; static constexpr bool is_losslessly_convertible_to_native = false; - static constexpr bool is_signed = static_cast(-1) < T{}; // for impls not properly specializing + static constexpr bool is_signed = static_cast(-1) < T{}; // for impls not specializing std::is_signed static constexpr bool can_represent_native = is_signed; static constexpr bool can_partially_represent_native = true; static constexpr auto node_type = ::toml::node_type::integer; @@ -487,7 +463,9 @@ namespace toml::impl template <> struct value_traits<__int128_t> : big_integer_value_traits<__int128_t> { - static constexpr auto max = static_cast<__int128_t>(( __uint128_t{ 1u } << ((__SIZEOF_INT128__ * CHAR_BIT) - 1)) - 1); + static constexpr auto max = static_cast<__int128_t>( + ( __uint128_t{ 1u } << ((__SIZEOF_INT128__ * CHAR_BIT) - 1)) - 1 + ); static constexpr auto min = -max - __int128_t{ 1 }; }; template <> @@ -551,11 +529,11 @@ namespace toml::impl static_assert(value_traits::can_partially_represent_native); // string value traits - + template struct string_value_traits { - using native_type = ::toml::string; + using native_type = std::string; static constexpr bool is_native = std::is_same_v; static constexpr bool is_losslessly_convertible_to_native = true; static constexpr bool can_represent_native @@ -582,7 +560,7 @@ namespace toml::impl template struct wstring_value_traits { - using native_type = ::toml::string; + using native_type = std::string; static constexpr bool is_native = false; static constexpr bool is_losslessly_convertible_to_native = true; //narrow static constexpr bool can_represent_native = std::is_same_v; //widen @@ -613,7 +591,7 @@ namespace toml::impl template <> struct value_traits : native_value_traits {}; template <> struct value_traits