Skip to content

Commit

Permalink
Revert "node/convert: relax the check for string_view (#1222)" (#1225)
Browse files Browse the repository at this point in the history
This reverts commit 6262201.

in 6262201, 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 6262201 is buggy. because it uses `<version>` to tell
the feature set provided by the standard library. but `<version>`
is a part of C++20. so this defeats the purpose of the change of
6262201.

Fixes #1223
  • Loading branch information
tchaikov committed Sep 10, 2023
1 parent 6262201 commit 2383e6d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions include/yaml-cpp/node/convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
#include <type_traits>
#include <valarray>
#include <vector>
#include <version>

#ifdef __cpp_lib_string_view
#if __cplusplus >= 201703L
#include <string_view>
#endif

Expand Down Expand Up @@ -94,7 +93,7 @@ struct convert<char[N]> {
static Node encode(const char* rhs) { return Node(rhs); }
};

#ifdef __cpp_lib_string_view
#if __cplusplus >= 201703L
template <>
struct convert<std::string_view> {
static Node encode(std::string_view rhs) { return Node(std::string(rhs)); }
Expand Down

0 comments on commit 2383e6d

Please sign in to comment.