From 38fa1f077c641d62f4d33e3841216b5cec910867 Mon Sep 17 00:00:00 2001 From: Elias Kosunen Date: Wed, 1 Nov 2023 01:20:00 +0200 Subject: [PATCH] Fix issue with wrap(string_view&&) being ambiguous --- include/scn/detail/range.h | 4 ++-- test/std_string_view.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/scn/detail/range.h b/include/scn/detail/range.h index 5b8802f8..0ef46dfb 100644 --- a/include/scn/detail/range.h +++ b/include/scn/detail/range.h @@ -522,8 +522,8 @@ namespace scn { #if SCN_HAS_STRING_VIEW template - static auto impl(const std::basic_string_view& str, - priority_tag<1>) noexcept + static auto impl(std::basic_string_view str, + priority_tag<2>) noexcept -> range_wrapper> { return {basic_string_view{str.data(), str.size()}}; diff --git a/test/std_string_view.cpp b/test/std_string_view.cpp index 35e85fa5..3f3a2abc 100644 --- a/test/std_string_view.cpp +++ b/test/std_string_view.cpp @@ -41,4 +41,11 @@ TEST_CASE("getline std::string_view") CHECK_EQ(std::memcmp(sv.data(), "foo", 3), 0); } +TEST_CASE("input std::string_view") +{ + std::string_view out; + auto ret = scn::scan(std::string_view{"foo"}, "{}", out); + CHECK(ret); + CHECK_EQ(out, "foo"); +} #endif