mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 10:28:09 +08:00
fix: correct SFINAE conditions and types
This commit is contained in:
15
toml/get.hpp
15
toml/get.hpp
@@ -635,9 +635,7 @@ get_or(const basic_value<C, M, V>& v, T&& opt)
|
|||||||
}
|
}
|
||||||
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>
|
||||||
detail::enable_if_t<std::is_same<
|
detail::enable_if_t<std::is_same<T, std::string>::value, std::string>&
|
||||||
typename std::remove_cv<typename std::remove_reference<T>::type>::type,
|
|
||||||
std::string>::value, std::string>&
|
|
||||||
get_or(basic_value<C, M, V>& v, T& opt)
|
get_or(basic_value<C, M, V>& v, T& opt)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -662,7 +660,7 @@ get_or(basic_value<C, M, V>&& v, T&& opt)
|
|||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
return opt;
|
return std::string(opt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,7 +671,7 @@ template<typename T, typename C,
|
|||||||
template<typename ...> class M, template<typename ...> class V>
|
template<typename ...> class M, template<typename ...> class V>
|
||||||
detail::enable_if_t<detail::is_string_literal<
|
detail::enable_if_t<detail::is_string_literal<
|
||||||
typename std::remove_reference<T>::type>::value, std::string>
|
typename std::remove_reference<T>::type>::value, std::string>
|
||||||
get_or(basic_value<C, M, V>&& v, T&& opt)
|
get_or(const basic_value<C, M, V>& v, T&& opt)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -692,9 +690,10 @@ template<typename T, typename C,
|
|||||||
template<typename ...> class M, template<typename ...> class V>
|
template<typename ...> class M, template<typename ...> class V>
|
||||||
detail::enable_if_t<detail::conjunction<
|
detail::enable_if_t<detail::conjunction<
|
||||||
detail::negation<detail::is_exact_toml_type<T, basic_value<C, M, V>>>,
|
detail::negation<detail::is_exact_toml_type<T, basic_value<C, M, V>>>,
|
||||||
detail::negation<std::is_same<T, std::string>>,
|
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>>
|
detail::negation<detail::is_string_literal<typename std::remove_reference<T>::type>>
|
||||||
>::value, T>
|
>::value, typename std::remove_reference<T>::type>
|
||||||
get_or(const basic_value<C, M, V>& v, T&& opt)
|
get_or(const basic_value<C, M, V>& v, T&& opt)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -704,7 +703,7 @@ get_or(const basic_value<C, M, V>& v, T&& opt)
|
|||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
return opt;
|
return std::forward<T>(opt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user