mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
fix: correct some SFINAE expressions
This commit is contained in:
33
toml/get.hpp
33
toml/get.hpp
@@ -541,9 +541,12 @@ std::string get_or(const toml::value& v, T&& opt)
|
|||||||
// others (require type conversion and return type cannot be lvalue reference)
|
// others (require type conversion and return type cannot be lvalue reference)
|
||||||
|
|
||||||
template<typename T, typename std::enable_if<detail::conjunction<
|
template<typename T, typename std::enable_if<detail::conjunction<
|
||||||
detail::negation<detail::is_exact_toml_type<T>>,
|
detail::negation<detail::is_exact_toml_type<
|
||||||
detail::negation<std::is_same<T, std::string>>,
|
typename std::remove_cv<typename std::remove_reference<T>::type>::type>>,
|
||||||
detail::negation<detail::is_string_literal<typename std::remove_reference<T>::type>>
|
detail::negation<std::is_same<std::string,
|
||||||
|
typename std::remove_cv<typename std::remove_reference<T>::type>::type>>,
|
||||||
|
detail::negation<detail::is_string_literal<
|
||||||
|
typename std::remove_reference<T>::type>>
|
||||||
>::value, std::nullptr_t>::type = nullptr>
|
>::value, std::nullptr_t>::type = nullptr>
|
||||||
T get_or(const toml::value& v, T&& opt)
|
T get_or(const toml::value& v, T&& opt)
|
||||||
{
|
{
|
||||||
@@ -554,7 +557,7 @@ T get_or(const toml::value& v, T&& opt)
|
|||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
return opt;
|
return T(std::move(opt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -639,9 +642,12 @@ std::string find_or(const toml::value& v, const toml::key& ky, T&& opt)
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// others (require type conversion and return type cannot be lvalue reference)
|
// others (require type conversion and return type cannot be lvalue reference)
|
||||||
template<typename T, typename std::enable_if<detail::conjunction<
|
template<typename T, typename std::enable_if<detail::conjunction<
|
||||||
detail::negation<detail::is_exact_toml_type<T>>,
|
detail::negation<detail::is_exact_toml_type<
|
||||||
detail::negation<std::is_same<T, std::string>>,
|
typename std::remove_cv<typename std::remove_reference<T>::type>::type>>,
|
||||||
detail::negation<detail::is_string_literal<typename std::remove_reference<T>::type>>
|
detail::negation<std::is_same<std::string,
|
||||||
|
typename std::remove_cv<typename std::remove_reference<T>::type>::type>>,
|
||||||
|
detail::negation<detail::is_string_literal<
|
||||||
|
typename std::remove_reference<T>::type>>
|
||||||
>::value, std::nullptr_t>::type = nullptr>
|
>::value, std::nullptr_t>::type = nullptr>
|
||||||
T find_or(const toml::value& v, const toml::key& ky, T&& opt)
|
T find_or(const toml::value& v, const toml::key& ky, T&& opt)
|
||||||
{
|
{
|
||||||
@@ -651,8 +657,8 @@ T find_or(const toml::value& v, const toml::key& ky, T&& opt)
|
|||||||
return get_or(tab.at(ky), std::forward<T>(opt));
|
return get_or(tab.at(ky), std::forward<T>(opt));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ---------------------------------------------------------------------------
|
||||||
// find_or(table, key, opt)
|
// toml::find(table)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// exact types (return type can be a reference)
|
// exact types (return type can be a reference)
|
||||||
@@ -718,9 +724,12 @@ std::string find_or(const toml::table& tab, const toml::key& ky, T&& opt)
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// others (require type conversion and return type cannot be lvalue reference)
|
// others (require type conversion and return type cannot be lvalue reference)
|
||||||
template<typename T, typename std::enable_if<detail::conjunction<
|
template<typename T, typename std::enable_if<detail::conjunction<
|
||||||
detail::negation<detail::is_exact_toml_type<T>>,
|
detail::negation<detail::is_exact_toml_type<
|
||||||
detail::negation<std::is_same<T, std::string>>,
|
typename std::remove_cv<typename std::remove_reference<T>::type>::type>>,
|
||||||
detail::negation<detail::is_string_literal<typename std::remove_reference<T>::type>>
|
detail::negation<std::is_same<std::string,
|
||||||
|
typename std::remove_cv<typename std::remove_reference<T>::type>::type>>,
|
||||||
|
detail::negation<detail::is_string_literal<
|
||||||
|
typename std::remove_reference<T>::type>>
|
||||||
>::value, std::nullptr_t>::type = nullptr>
|
>::value, std::nullptr_t>::type = nullptr>
|
||||||
T find_or(const toml::table& tab, const toml::key& ky, T&& opt)
|
T find_or(const toml::table& tab, const toml::key& ky, T&& opt)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user