From 2383e6d0f29c95587bf49890af10f0b8557a8cd1 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 10 Sep 2023 20:28:52 +0800 Subject: [PATCH] Revert "node/convert: relax the check for string_view (#1222)" (#1225) This reverts commit 6262201182a0ee357d8a456e6d1a8e5984e4c6dd. in 62622011, we wanted address the needs to use the `string_view` converter in C++98, but that requirement was based on wrong preconditions. `std::string_view` was introduced in C++17, and popular standard libraries like libstdc++ and libc++ both provide `std::string_view` when the source is built with C++17. furthermore 62622011 is buggy. because it uses `` to tell the feature set provided by the standard library. but `` is a part of C++20. so this defeats the purpose of the change of 62622011. Fixes #1223 --- include/yaml-cpp/node/convert.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/yaml-cpp/node/convert.h b/include/yaml-cpp/node/convert.h index 9dea370..d0eb450 100644 --- a/include/yaml-cpp/node/convert.h +++ b/include/yaml-cpp/node/convert.h @@ -17,9 +17,8 @@ #include #include #include -#include -#ifdef __cpp_lib_string_view +#if __cplusplus >= 201703L #include #endif @@ -94,7 +93,7 @@ struct convert { static Node encode(const char* rhs) { return Node(rhs); } }; -#ifdef __cpp_lib_string_view +#if __cplusplus >= 201703L template <> struct convert { static Node encode(std::string_view rhs) { return Node(std::string(rhs)); }