From bad22f4846ae5eab5cb761f75f7f47079871f8d6 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 6 Sep 2023 12:46:18 +0800 Subject: [PATCH] node/convert: relax the check for string_view in 35b44980, the conversion for `std::string_view` was added, but it enables it only if C++17 is used. but the availability of `std::string_view` does not depends on C++17. in this change, we use the more specific language feature macro to check the availability of `std::string_view` instead of checking for the C++ standard. Refs #1148 Signed-off-by: Kefu Chai --- include/yaml-cpp/node/convert.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/yaml-cpp/node/convert.h b/include/yaml-cpp/node/convert.h index d0eb450..9dea370 100644 --- a/include/yaml-cpp/node/convert.h +++ b/include/yaml-cpp/node/convert.h @@ -17,8 +17,9 @@ #include #include #include +#include -#if __cplusplus >= 201703L +#ifdef __cpp_lib_string_view #include #endif @@ -93,7 +94,7 @@ struct convert { static Node encode(const char* rhs) { return Node(rhs); } }; -#if __cplusplus >= 201703L +#ifdef __cpp_lib_string_view template <> struct convert { static Node encode(std::string_view rhs) { return Node(std::string(rhs)); }