mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-09 22:30:07 +00:00
enable to get toml::value as toml::value
This commit is contained in:
parent
0c08b9e940
commit
c2e733a65d
@ -116,6 +116,14 @@ BOOST_AUTO_TEST_CASE(test_get_exact)
|
||||
tab["key3"] = toml::value(123);
|
||||
BOOST_CHECK(tab == toml::get<toml::table>(v));
|
||||
}
|
||||
{
|
||||
toml::value v1(42);
|
||||
BOOST_CHECK(v1 == toml::get<toml::value>(v1));
|
||||
|
||||
toml::value v2(54);
|
||||
toml::get<toml::value>(v1) = v2;
|
||||
BOOST_CHECK(v2 == toml::get<toml::table>(v1));
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_get_integer_type)
|
||||
|
24
toml/get.hpp
24
toml/get.hpp
@ -33,6 +33,30 @@ inline T&& get(value&& v)
|
||||
return std::move(v.cast<detail::toml_value_t<T>::value>());
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// T == toml::value; identity transformation.
|
||||
|
||||
template<typename T, typename std::enable_if<
|
||||
std::is_same<T, ::toml::value>::value, std::nullptr_t>::type = nullptr>
|
||||
inline T& get(value& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if<
|
||||
std::is_same<T, ::toml::value>::value, std::nullptr_t>::type = nullptr>
|
||||
inline T const& get(const value& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if<
|
||||
std::is_same<T, ::toml::value>::value, std::nullptr_t>::type = nullptr>
|
||||
inline T&& get(value&& v)
|
||||
{
|
||||
return std::move(v);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// integer convertible from toml::Integer
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user