I had to remove the implementation of std::basic_string_view for pre-C++17 since it didn't allow me to pass string_view object to fmt, it said (it didn't know how to convert from basic_string_view to basic_string_view). After that, it worked.
There is an implicit conversion from std::basic_string_view to fmt::basic_string_view: https://github.com/fmtlib/fmt/blob/84e520b79c9c894c6e71a979660fc1278e032dd4/include/fmt/core.h#L240 so the following should work:
fmt::format(std::string_view("{}"), 42);
provided that string_view is detected on your platform. Which compiler version do you use?
I’m using clang 5 in macOS it didn’t work until I removed the custom basic_string_view; and apparently it did detect it.
Hmm, according to godbolt std::string_view is detected and works: https://godbolt.org/g/3n2XBe
Could you post a reproducible example and the full error message?
Done! Probably detection isn’t lacking, since std::string_view is available since c++14 in clang 4 and 5. Simply change to -std=c++14 so you see it fail (note it does have std::string_view available anyway)
C++14 doesn't have std::string_view, so the error is expected. You can use std::experimental::string_view with C++14: https://godbolt.org/g/eFMRTQ
...well, I’m successfully using std::string_view all over the place in clang 4 and 5 c++14, so I guess we could support it too, couldn’t we?
What compiler flags do you use? std::string_view is not supported with -std=c++14: https://godbolt.org/g/LLKw3P
libc++ supports it in C++14, and apparently back to C++03, see
https://github.com/abseil/abseil-cpp/issues/2
On Wed, Mar 21, 2018, 18:32 Victor Zverovich notifications@github.com
wrote:
What compiler flags do you use? std::string_view is not supported with
-std=c++14: https://godbolt.org/g/LLKw3P—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/fmtlib/fmt/issues/686#issuecomment-375149244, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABCB7wo5Z4KRtC6_XvM5fMqBM4F10E0nks5tgv8UgaJpZM4Sy6FP
.
Fixed, thanks for reporting!
Most helpful comment
libc++ supports it in C++14, and apparently back to C++03, see
https://github.com/abseil/abseil-cpp/issues/2
On Wed, Mar 21, 2018, 18:32 Victor Zverovich notifications@github.com
wrote: