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

Compatibility with std::string_view? #159

Closed
mateofio opened this issue May 8, 2015 · 1 comment
Closed

Compatibility with std::string_view? #159

mateofio opened this issue May 8, 2015 · 1 comment

Comments

@mateofio
Copy link

mateofio commented May 8, 2015

std::string_view is slated for C++17 and there is already support for a std::experimental::string_view.
http://en.cppreference.com/w/cpp/experimental/basic_string_view

In addition, many projects have their own implementation of string_view.

I noticed your StringRef class contains a method called c_str(). If you are following the STL paradigm, the existance of this method means that your StringRef class has an invariant that must always reference a null terminated string and therefore the formatting functions require the format string to be null terminated.

Is this the case?

If not, I would suggest renaming StringRef::c_str() to StringRef::data(). I'd also add whether or not null termination is required on the format string to the documentation.

If you are planning to support non-null terminated format strings, a constructor accepting a std::experimental::string_view (conditionally enabled with the __cpp_lib_experimental_string_view macro) with also help people using string_view use your library.

@vitaut
Copy link
Contributor

vitaut commented May 8, 2015

Thanks for the suggestion. Replacing StringRef::c_str() to StringRef::data() is already on my TODO list (#100). I'll add a note regarding std::experimental::string_view there.

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

2 participants