mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
feat: enable toml::get with std::string_view
This commit is contained in:
12
toml/get.hpp
12
toml/get.hpp
@@ -108,6 +108,18 @@ inline std::string get(value&& v)
|
||||
return std::move(v.cast<value_t::String>().str);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// std::string_view
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
template<typename T, typename std::enable_if<
|
||||
std::is_same<T, std::string_view>::value, std::nullptr_t>::type = nullptr>
|
||||
inline std::string_view get(const value& v)
|
||||
{
|
||||
return std::string_view(v.cast<value_t::String>().str);
|
||||
}
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
// std::chrono::duration from toml::local_time.
|
||||
|
||||
|
Reference in New Issue
Block a user