From b6e2c6e235b18fcf581ff376363b273e789050f4 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Fri, 14 May 2021 15:46:00 +0900 Subject: [PATCH] feat: add detail::has_specialization_from/into --- toml/traits.hpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/toml/traits.hpp b/toml/traits.hpp index eafa6af..209856d 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(std::nullptr_t, std::size_t S = sizeof(::toml::from)); +}; +struct has_specialized_into_impl +{ + template + static std::false_type check(...); + template + static std::true_type check(std::nullptr_t, std::size_t S = sizeof(::toml::into)); +}; + + /// 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