From d061c33a1695b637aca5f3fdc6b348bc314a1605 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Tue, 23 Apr 2019 23:24:23 +0900 Subject: [PATCH] feat: enable toml::get with std::string_view --- toml/get.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/toml/get.hpp b/toml/get.hpp index c0e47bb..344519f 100644 --- a/toml/get.hpp +++ b/toml/get.hpp @@ -108,6 +108,18 @@ inline std::string get(value&& v) return std::move(v.cast().str); } +// ============================================================================ +// std::string_view + +#if __cplusplus >= 201703L +template::value, std::nullptr_t>::type = nullptr> +inline std::string_view get(const value& v) +{ + return std::string_view(v.cast().str); +} +#endif + // ============================================================================ // std::chrono::duration from toml::local_time.