diff --git a/toml/traits.hpp b/toml/traits.hpp index 7f5654b..98f524b 100644 --- a/toml/traits.hpp +++ b/toml/traits.hpp @@ -6,6 +6,12 @@ #include #include #include +#include +#if __cplusplus >= 201703L +#if __has_include() +#include +#endif // has_include() +#endif // cplusplus >= C++17 namespace toml { @@ -81,7 +87,6 @@ struct has_mapped_type : decltype(has_mapped_type_impl::check(nullptr)){}; template struct has_resize_method : decltype(has_resize_method_impl::check(nullptr)){}; - template struct has_from_toml_method : decltype(has_from_toml_method_impl::check(nullptr)){}; @@ -114,7 +119,7 @@ template struct negation : std::integral_constant(T::value)>{}; // --------------------------------------------------------------------------- -// normal type checker +// type checkers template struct is_std_pair : std::false_type{}; template @@ -128,6 +133,33 @@ template struct is_chrono_duration: std::false_type{}; template struct is_chrono_duration>: std::true_type{}; +template +struct is_map : conjunction< // map satisfies all the following conditions + has_iterator, // has T::iterator + has_value_type, // has T::value_type + has_key_type, // has T::key_type + has_mapped_type // has T::mapped_type + >{}; +template struct is_map : is_map{}; +template struct is_map : is_map{}; +template struct is_map : is_map{}; +template struct is_map : is_map{}; + +template +struct is_container : conjunction< + negation>, // not a map + negation>, // not a std::string +#if __cplusplus >= 201703L + negation>, // not a std::string_view +#endif + has_iterator, // has T::iterator + has_value_type // has T::value_type + >{}; +template struct is_container : is_container{}; +template struct is_container : is_container{}; +template struct is_container : is_container{}; +template struct is_container : is_container{}; + // --------------------------------------------------------------------------- // C++14 index_sequence diff --git a/toml/types.hpp b/toml/types.hpp index a221d84..47c9248 100644 --- a/toml/types.hpp +++ b/toml/types.hpp @@ -7,11 +7,6 @@ #include "traits.hpp" #include #include -#if __cplusplus >= 201703L -#if __has_include() -#include -#endif -#endif namespace toml { @@ -161,34 +156,6 @@ template struct is_exact_toml_type : is_exact_toml template struct is_exact_toml_type : is_exact_toml_type{}; template struct is_exact_toml_type: is_exact_toml_type{}; -template -struct is_map : conjunction< - has_iterator, - has_value_type, - has_key_type, - has_mapped_type - >{}; -template struct is_map : is_map{}; -template struct is_map : is_map{}; -template struct is_map : is_map{}; -template struct is_map : is_map{}; - -template -struct is_container : conjunction< - negation>, - negation>, -#if __cplusplus >= 201703L - negation>, -#endif - has_iterator, - has_value_type - >{}; -template struct is_container : is_container{}; -template struct is_container : is_container{}; -template struct is_container : is_container{}; -template struct is_container : is_container{}; - - } // detail } // toml #endif// TOML11_TYPES_H