Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of basic_string_view clashes with std #686

Closed
Kronuz opened this issue Mar 21, 2018 · 10 comments
Closed

Implementation of basic_string_view clashes with std #686

Kronuz opened this issue Mar 21, 2018 · 10 comments

Comments

@Kronuz
Copy link
Contributor

Kronuz commented Mar 21, 2018

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.

@vitaut
Copy link
Contributor

vitaut commented Mar 21, 2018

There is an implicit conversion from std::basic_string_view to fmt::basic_string_view:

FMT_CONSTEXPR basic_string_view(type s) FMT_NOEXCEPT
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?

@Kronuz
Copy link
Contributor Author

Kronuz commented Mar 21, 2018

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.

@vitaut
Copy link
Contributor

vitaut commented Mar 21, 2018

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?

@Kronuz
Copy link
Contributor Author

Kronuz commented Mar 22, 2018

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)

@vitaut
Copy link
Contributor

vitaut commented Mar 22, 2018

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

@vitaut vitaut closed this as completed Mar 22, 2018
@Kronuz
Copy link
Contributor Author

Kronuz commented Mar 22, 2018

...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?

@vitaut
Copy link
Contributor

vitaut commented Mar 22, 2018

What compiler flags do you use? std::string_view is not supported with -std=c++14: https://godbolt.org/g/LLKw3P

@mwinterb
Copy link
Contributor

mwinterb commented Mar 22, 2018 via email

@Kronuz
Copy link
Contributor Author

Kronuz commented Mar 22, 2018

https://wandbox.org/permlink/5wvB24tzaF3ggxgb

@vitaut vitaut reopened this Mar 23, 2018
vitaut added a commit that referenced this issue Mar 26, 2018
@vitaut
Copy link
Contributor

vitaut commented Mar 26, 2018

Fixed, thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants