node/convert: relax the check for string_view (#1222)

This commit is contained in:
Kefu Chai
2023-09-06 20:57:12 +08:00
committed by GitHub
parent fcbb8193b9
commit 6262201182

View File

@@ -17,8 +17,9 @@
#include <type_traits> #include <type_traits>
#include <valarray> #include <valarray>
#include <vector> #include <vector>
#include <version>
#if __cplusplus >= 201703L #ifdef __cpp_lib_string_view
#include <string_view> #include <string_view>
#endif #endif
@@ -93,7 +94,7 @@ struct convert<char[N]> {
static Node encode(const char* rhs) { return Node(rhs); } static Node encode(const char* rhs) { return Node(rhs); }
}; };
#if __cplusplus >= 201703L #ifdef __cpp_lib_string_view
template <> template <>
struct convert<std::string_view> { struct convert<std::string_view> {
static Node encode(std::string_view rhs) { return Node(std::string(rhs)); } static Node encode(std::string_view rhs) { return Node(std::string(rhs)); }