cxxomfort
rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
|
Backports related to Standard header <string_view>
Interfaces defined here:
basic_string_view
- view to a string-like object (C++17).string_view
, wstring_view
.CXXOMFORT_IMPLEMENTS_stdheader_string_view
- implementation status for the above.""sv
to C++11 upto C++14.For differences between the implementation of string_view
here vs standard, check the notices at basic_string_view
Fixes / Interfaces not in std:
cxxomfort::fix::sv()
C++17 onwards defines operator"" sv
as the user-defined literal to create basic_string_view
objects. The cxxomfort library backports the string_view
and wstring_view
capable versions of this user-defined literal.
""sv
is reserved. While this means the library is functioning correctly in that it can add the literal operator, it is compiler-dependent whether it is possible to disable this warning or error (see eg.: https://stackoverflow.com/questions/31509434/gcc-does-not-honor-pragma-gcc-diagnostic-to-silence-warnings ).-isystem
.The helper function sv() creates a basic_string_view
. It is provided to serve as a supplement to the "user-defined literal" ""sv
where it is not available:
C++20 and C++23 add new member functions to basic_string
and basic_string_view
. Since it is not possible in C++ to extend a class with new methods, and the interface for basic_string is already crap (see []), cxxomfort implements them as nonmember accessors à-la-<iterator>
.
For relevant documentation see Nonmember helpers for string types .