diff --git a/toml/traits.hpp b/toml/traits.hpp index 79bb8b2..1991728 100644 --- a/toml/traits.hpp +++ b/toml/traits.hpp @@ -9,6 +9,9 @@ namespace toml { + +class value; // forward decl + namespace detail { @@ -45,6 +48,22 @@ struct has_resize_method_impl template static std::false_type check(...); }; +struct has_from_toml_method_impl +{ + template + static std::true_type check( + decltype(std::declval().from_toml(std::declval<::toml::value>()))*); + template + static std::false_type check(...); +}; +struct has_into_toml_method_impl +{ + template + static std::true_type check(decltype(std::declval().into_toml())*); + template + static std::false_type check(...); +}; + /// 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 @@ -62,6 +81,14 @@ 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)){}; +template +struct has_into_toml_method +: decltype(has_into_toml_method_impl::check(nullptr)){}; + #ifdef __INTEL_COMPILER #undef decltype(...) #endif