diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 04ab80b..2a20744 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: # g++-4.8 and 4.9 are tested on Travis.CI. - compiler: ['g++-9', 'g++-8', 'g++-7', 'g++-6', 'g++-5'] + compiler: ['g++-11', 'g++-10', 'g++-9', 'g++-8', 'g++-7', 'g++-6', 'g++-5'] standard: ['11', '14', '17', '20'] exclude: - {compiler: 'g++-5', standard: '17'} @@ -59,6 +59,7 @@ jobs: - {compiler: '6.0', standard: '20'} - {compiler: '7', standard: '20'} - {compiler: '8', standard: '20'} + - {compiler: '9', standard: '20'} steps: - name: Checkout uses: actions/checkout@v2 diff --git a/toml/get.hpp b/toml/get.hpp index 5095caf..a766f4a 100644 --- a/toml/get.hpp +++ b/toml/get.hpp @@ -255,16 +255,19 @@ get(const basic_value&); // toml::from::from_toml(v) template class M, template class V, - std::size_t S = sizeof(::toml::from)> -T get(const basic_value&); + template class M, template class V> +detail::enable_if_t::value, T> +get(const basic_value&); -// T(const toml::value&) and T is not toml::basic_value +// T(const toml::value&) and T is not toml::basic_value, +// and it does not have `from` nor `from_toml`. template class M, template class V> detail::enable_if_t>, - std::is_constructible&> + std::is_constructible&>, + detail::negation>, + detail::negation> >::value, T> get(const basic_value&); @@ -440,9 +443,9 @@ get(const basic_value& v) return ud; } template class M, template class V, - std::size_t> -T get(const basic_value& v) + template class M, template class V> +detail::enable_if_t::value, T> +get(const basic_value& v) { return ::toml::from::from_toml(v); } @@ -450,8 +453,10 @@ T get(const basic_value& v) template class M, template class V> detail::enable_if_t>, - std::is_constructible&> + detail::negation>, // T is not a toml::value + std::is_constructible&>, // T is constructible from toml::value + detail::negation>, // and T does not have T.from_toml(v); + detail::negation> // and T does not have toml::from{}; >::value, T> get(const basic_value& v) { diff --git a/toml/traits.hpp b/toml/traits.hpp index eafa6af..0064e37 100644 --- a/toml/traits.hpp +++ b/toml/traits.hpp @@ -2,6 +2,10 @@ // Distributed under the MIT License. #ifndef TOML11_TRAITS_HPP #define TOML11_TRAITS_HPP + +#include "from.hpp" +#include "into.hpp" + #include #include #include @@ -84,6 +88,22 @@ struct has_into_toml_method_impl static std::false_type check(...); }; +struct has_specialized_from_impl +{ + template + static std::false_type check(...); + template)> + static std::true_type check(::toml::from*); +}; +struct has_specialized_into_impl +{ + template + static std::false_type check(...); + template)> + static std::true_type check(::toml::from*); +}; + + /// Intel C++ compiler can not use decltype in parent class declaration, here /// is a hack to work around it. https://stackoverflow.com/a/23953090/4692076 #ifdef __INTEL_COMPILER @@ -114,6 +134,11 @@ template struct has_into_toml_method : decltype(has_into_toml_method_impl::check(nullptr)){}; +template +struct has_specialized_from : decltype(has_specialized_from_impl::check(nullptr)){}; +template +struct has_specialized_into : decltype(has_specialized_into_impl::check(nullptr)){}; + #ifdef __INTEL_COMPILER #undef decltype #endif