diff --git a/toml/string.hpp b/toml/string.hpp index 89e6d39..abd58b5 100644 --- a/toml/string.hpp +++ b/toml/string.hpp @@ -4,6 +4,11 @@ #define TOML11_STRING_HPP #include #include +#if __cplusplus >= 201703L +#if __has_include() +#include +#endif +#endif namespace toml { @@ -40,6 +45,17 @@ struct string operator std::string const& () const& noexcept {return str;} operator std::string&& () && noexcept {return std::move(str);} +#if __cplusplus >= 201703L + explicit string(std::string_view s): kind(string_t::basic), str(s){} + string(std::string_view s, string_t k): kind(k), str(s){} + + string& operator=(std::string_view s) + {kind = string_t::basic; str = s; return *this;} + + explicit operator std::string_view() const noexcept + {return std::string_view(str);} +#endif + string_t kind; std::string str; };