refactor: use has_specialized_from<T>

to check if toml::from<T> exists for a specific T
This commit is contained in:
ToruNiina
2021-05-14 15:53:34 +09:00
parent b6e2c6e235
commit 72ee8caf09

View File

@@ -255,9 +255,9 @@ get(const basic_value<C, M, V>&);
// toml::from<T>::from_toml(v) // toml::from<T>::from_toml(v)
template<typename T, typename C, template<typename T, typename C,
template<typename ...> class M, template<typename ...> class V, template<typename ...> class M, template<typename ...> class V>
std::size_t S = sizeof(::toml::from<T>)> detail::enable_if_t<detail::has_specialized_from<T>::value, T>
T get(const basic_value<C, M, V>&); get(const basic_value<C, M, V>&);
// T(const toml::value&) and T is not toml::basic_value // T(const toml::value&) and T is not toml::basic_value
template<typename T, typename C, template<typename T, typename C,
@@ -440,9 +440,9 @@ get(const basic_value<C, M, V>& v)
return ud; return ud;
} }
template<typename T, typename C, template<typename T, typename C,
template<typename ...> class M, template<typename ...> class V, template<typename ...> class M, template<typename ...> class V>
std::size_t> detail::enable_if_t<detail::has_specialized_from<T>::value, T>
T get(const basic_value<C, M, V>& v) get(const basic_value<C, M, V>& v)
{ {
return ::toml::from<T>::from_toml(v); return ::toml::from<T>::from_toml(v);
} }