Skip to content

Compatibility with std::string_view? #159

@mateofio

Description

@mateofio

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions