From 0ac3919e084307e2c6be0d1a549830cfe19aed31 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Fri, 14 May 2021 16:05:54 +0900 Subject: [PATCH] feat: from and from_toml precede constructor constructor sometimes has `template ctor(const T&)` and it causes ambiguity. To avoid it, from and T.from_toml precedes any constructor. But, to check the ambiguity between from and from_toml, they do not precede each other. If anyone define both from and from_toml, it causes compilation error. --- toml/get.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/toml/get.hpp b/toml/get.hpp index 9a5a855..a766f4a 100644 --- a/toml/get.hpp +++ b/toml/get.hpp @@ -259,12 +259,15 @@ template::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&); @@ -450,8 +453,10 @@ 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) {