From 6957d28cfb924f6b068c3d7347b889eb3a1a7f97 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 26 Mar 2018 06:50:22 -1000 Subject: [PATCH] Detect string_view on libc++ (#686) --- include/fmt/core.h | 3 ++- test/format-test.cc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 3ddb3b4a..f519b5d9 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -156,7 +156,8 @@ void operator=(const Type &) FMT_DELETED #if (FMT_HAS_INCLUDE() && __cplusplus > 201402L) || \ - (defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910) + (defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910) || \ + _LIBCPP_VERSION // libc++ supports string_view in pre-c++17 # include # define FMT_USE_STD_STRING_VIEW // std::experimental::basic_string_view::remove_prefix isn't constexpr until diff --git a/test/format-test.cc b/test/format-test.cc index 0ea41c83..8c35dc43 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1201,7 +1201,7 @@ TEST(FormatterTest, FormatStringView) { } #ifdef FMT_USE_STD_STRING_VIEW -TEST(FormatterTest, FormatStringView) { +TEST(FormatterTest, FormatStdStringView) { EXPECT_EQ("test", format("{0}", std::string_view("test"))); } #endif