{"id":13730280,"url":"https://github.com/martinmoene/string-view-lite","last_synced_at":"2025-05-15T20:04:48.242Z","repository":{"id":37622981,"uuid":"114163412","full_name":"martinmoene/string-view-lite","owner":"martinmoene","description":"string_view lite - A C++17-like string_view for C++98, C++11 and later in a single-file header-only library","archived":false,"fork":false,"pushed_at":"2025-03-24T08:29:02.000Z","size":274,"stargazers_count":436,"open_issues_count":5,"forks_count":46,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-19T02:14:50.404Z","etag":null,"topics":["cpp17","cpp98","header-only","no-dependencies","single-file","string-view","string-view-implementations"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/martinmoene.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-13T20:01:02.000Z","updated_at":"2025-04-18T16:28:26.000Z","dependencies_parsed_at":"2024-01-14T16:45:12.643Z","dependency_job_id":"a409e26d-304a-4989-a5a6-4d7838aaf821","html_url":"https://github.com/martinmoene/string-view-lite","commit_stats":{"total_commits":276,"total_committers":11,"mean_commits":25.09090909090909,"dds":"0.13043478260869568","last_synced_commit":"5b1d95fe2c0ee18e654876487898b9a423a954db"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinmoene%2Fstring-view-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinmoene%2Fstring-view-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinmoene%2Fstring-view-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinmoene%2Fstring-view-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinmoene","download_url":"https://codeload.github.com/martinmoene/string-view-lite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254414499,"owners_count":22067272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp17","cpp98","header-only","no-dependencies","single-file","string-view","string-view-implementations"],"created_at":"2024-08-03T02:01:12.711Z","updated_at":"2025-05-15T20:04:41.687Z","avatar_url":"https://github.com/martinmoene.png","language":"C++","readme":"# string_view lite: A single-file header-only version of a C++17-like string_view for C++98, C++11 and later\n\n[![Language](https://img.shields.io/badge/C%2B%2B-98/11/14/17-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization) [![License](https://img.shields.io/badge/license-BSL-blue.svg)](https://opensource.org/licenses/BSL-1.0) [![Build Status](https://github.com/martinmoene/string-view-lite/actions/workflows/ci.yml/badge.svg)](https://github.com/martinmoene/string-view-lite/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/1ha3wnxtam547m8p?svg=true)](https://ci.appveyor.com/project/martinmoene/string-view-lite) [![Version](https://badge.fury.io/gh/martinmoene%2Fstring-view-lite.svg)](https://github.com/martinmoene/string-view-lite/releases) [![download](https://img.shields.io/badge/latest-download-blue.svg)](https://github.com/martinmoene/string-view-lite/blob/master/include/nonstd/string_view.hpp) [![Conan](https://img.shields.io/badge/on-conan-blue.svg)](https://conan.io/center/string-view-lite) [![Vcpkg](https://img.shields.io/badge/on-vcpkg-blue.svg)](https://vcpkg.link/ports/string-view-lite) [![Try it on wandbox](https://img.shields.io/badge/on-wandbox-blue.svg)](https://wandbox.org/permlink/ZfX49QqynfuQikTX) [![Try it on godbolt online](https://img.shields.io/badge/on-godbolt-blue.svg)](https://godbolt.org/z/YtxnAn)\n\n**Contents**  \n\n- [Example usage](#example-usage)\n- [In a nutshell](#in-a-nutshell)\n- [License](#license)\n- [Dependencies](#dependencies)\n- [Installation](#installation)\n- [Synopsis](#synopsis)\n- [Reported to work with](#reported-to-work-with)\n- [Building the tests](#building-the-tests)\n- [Other implementations of string_view](#other-implementations-of-string_view)\n- [Notes and references](#notes-and-references)\n- [Appendix](#appendix)\n\n\n## Example usage\n\n```Cpp\n#include \"nonstd/string_view.hpp\"\n#include \u003ciostream\u003e\n\nusing namespace std::literals;\nusing namespace nonstd::literals;\nusing namespace nonstd;\n\nvoid write( string_view sv )\n{\n    std::cout \u003c\u003c sv;\n}\n\nint main()\n{\n    write( \"hello\"     );   // C-string\n    write( \", \"s       );   // std::string\n    write( \"world!\"_sv );   // nonstd::string_view\n}\n```\n\n### Compile and run\n\n```Text\nprompt\u003e g++ -Wall -std=c++14 -I../include/ -o 01-basic.exe 01-basic.cpp \u0026\u0026 01-basic.exe\nhello, world!\n```\n\n## In a nutshell\n\n**string-view lite** is a single-file header-only library to provide a non-owning reference to a string. The library provides a [C++17-like string_view](http://en.cppreference.com/w/cpp/string/basic_string_view) for use with C++98 and later. If available, `std::string_view` is used, unless [configured otherwise](#configuration).\n\n**Features and properties of string-view lite** are ease of installation (single header), freedom of dependencies other than the standard library. To mimic C++17-like cooperation with `std::string`, `nonstd::string_view` provides several non-standard conversion functions. These functions may be [omitted via configuration](#configuration).\n\n## License\n\n*string-view lite* is distributed under the [Boost Software License](LICENSE.txt).\n\n## Dependencies\n\n*string-view lite* has no other dependencies than the [C++ standard library](http://en.cppreference.com/w/cpp/header).\n\n## Installation\n\n*string-view lite* is a single-file header-only library. Put `string_view.hpp` in the [include](include) folder directly into the project source tree or somewhere reachable from your project.\n\nOr, if you use the [conan package manager](https://www.conan.io/), follow these steps:\n\n1. Add *nonstd-lite* to the conan remotes:\n\n        conan remote add nonstd-lite https://api.bintray.com/conan/martinmoene/nonstd-lite\n\n2. Add a reference to *string-view-lite* to the *requires* section of your project's `conanfile.txt` file:\n\n        [requires]\n        string-view-lite/[~=1]@nonstd-lite/testing\n\n3. Run conan's install command:\n\n        conan install\n\n## Synopsis\n\n**Contents**  \n[Documentation of `std::string_view`](#stdstring_view)  \n[C++20 extensions](#c20-extensions)  \n[Non-standard extensions](#non-standard-extensions)  \n[Configuration](#configuration)    \n\n## Documentation of `std::string_view`\n\nDepending on the compiler and C++-standard used, `nonstd::string_view` behaves less or more like `std::string_view`. To get an idea of the capabilities of `nonstd::string_view` with your configuration, look at the output of the [tests](test/string-view.t.cpp), issuing `string-view-lite.t --pass @`. For `std::string_view`, see its [documentation at cppreference](http://en.cppreference.com/w/cpp/string/basic_string_view).  \n\n## C++20 extensions\n\n*string_view-lite* provides the following C++20 *extensions*.\n\n- *[[nodiscard]]* constexpr bool **empty**() const noexcept;\n- constexpr bool ***starts_with***( basic_string_view v ) const noexcept;  // (1)\n- constexpr bool ***starts_with***( CharT c ) const noexcept;  // (2)\n- constexpr bool ***starts_with***( CharT const * s ) const;  // (3)\n- constexpr bool ***ends_with***( basic_string_view v ) const noexcept;  // (1)\n- constexpr bool ***ends_with***( CharT c ) const noexcept;  // (2)\n- constexpr bool ***ends_with***( CharT const * s ) const;  // (3)\n\nNote: [[nodiscard]], constexpr and noexcept if available.\n\n## Non-standard extensions\n\n### `string_view` literals `sv` and `_sv`\n\nclang compilers do not allow to write `auto sv = \"...\"sv` with *string-view lite* under C++11. To still provide a literal operator that can be used in that case, *string-view lite* also provides `_sv`. See section [Configuration](#configuration) for how to control the presence of these operators.\n\nThe literal operators are declared in the namespace `nonstd::literals::string_view_literals`, where both `literals` and `string_view_literals` are inline namespaces, if supported. Access to these operators can be gained with using namespace `nonstd::literals`, using namespace `nonstd::string_view_literals`, and using namespace `nonstd::literals::string_view_literals`. If inline namespaces are not supported by the compiler, only the latter form is available.\n\n### Cooperation between `std::string` and `nonstd::string_view`\n\n*string-view lite* can provide several methods and free functions to mimic the cooperation between `std::string` and  `nonstd::string_view` that exists in C++17. See the table below. Several macros allow you to control the presence of these functions, see section [Configuration](#configuration).\n\n| Kind                  | Std   | Function or method |\n|-----------------------|-------|--------------------|\n| **Free functions**    |\u0026nbsp; | macro `nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS`|\n| **`std::string_view`**|\u0026nbsp; | \u0026nbsp; |\n| to_string()           |\u003e=C++17| template\u0026lt; class CharT, class Traits, class Allocator=std::allocator\u0026lt;CharT\u003e \u003e\u003cbr\u003estd::basic_string\u0026lt;CharT, Traits, Allocator\u0026gt;\u003cbr\u003e**to_string**( std::basic_string_view\u0026lt;CharT, Traits\u003e v, Allocator const \u0026 a=Allocator() );|\n| to_string_view()      |\u003e=C++17| template\u0026lt; class CharT, class Traits, class Allocator \u003e\u003cbr\u003estd::basic_string_view\u0026lt;CharT, Traits\u003e\u003cbr\u003e**to_string_view**( std::basic_string\u0026lt;CharT, Traits, Allocator\u003e const \u0026 s );|\n| **`nonstd::string_view`**|\u0026nbsp; | \u0026nbsp;  |\n| to_string()\u003cbr\u003e\u0026nbsp;\u003cbr\u003e*non-msvc14 (vs2015)* |\u003e=C++11| template\u0026lt; class CharT, class Traits, class Allocator = std::allocator\u0026lt;CharT\u003e \u003e\u003cbr\u003estd::basic_string\u0026lt;CharT, Traits, Allocator\u003e\u003cbr\u003e**to_string**( basic_string_view\u0026lt;CharT, Traits\u003e v, Allocator const \u0026 a = Allocator() );|\n| to_string()\u003cbr\u003e\u0026nbsp;\u003cbr\u003e*msvc14 (vs2015)* |\u003cC++11|template\u0026lt; class CharT, class Traits \u003e\u003cbr\u003estd::basic_string\u0026lt;CharT, Traits\u003e\u003cbr\u003e**to_string**( basic_string_view\u0026lt;CharT, Traits\u003e v );|\n| to_string()\u003cbr\u003e\u0026nbsp;\u003cbr\u003e*msvc14 (vs2015)* |\u003cC++11|template\u0026lt; class CharT, class Traits, class Allocator \u003e\u003cbr\u003estd::basic_string\u0026lt;CharT, Traits, Allocator\u003e\u003cbr\u003e**to_string**( basic_string_view\u0026lt;CharT, Traits\u003e v, Allocator const \u0026 a );|\n| to_string_view()      |\u003e=C++98| template\u0026lt; class CharT, class Traits, class Allocator \u003e\u003cbr\u003ebasic_string_view\u0026lt;CharT, Traits\u003e\u003cbr\u003e**to_string_view**( std::basic_string\u0026lt;CharT, Traits, Allocator\u003e const \u0026 s );|\n| \u0026nbsp;                |\u0026nbsp; | \u0026nbsp; |\n| **Class methods**     |\u0026nbsp; | macro `nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS` |\n| **`nonstd::basic_string_view`**|\u0026nbsp; |\u0026nbsp; |\n| Constructor           |\u003e=C++98| template\u0026lt; class Allocator \u003e\u003cbr\u003e**basic_string_view**( std::basic_string\u0026lt;CharT, Traits, Allocator\u003e const \u0026 s ) nssv_noexcept;|\n| Converting operator   |\u003e=C++11| template\u0026lt; class Allocator \u003e\u003cbr\u003eexplicit **operator std::basic_string**\u0026lt;CharT, Traits, Allocator\u003e() const;|\n| to_string()           |\u003e=C++11| template\u0026lt; class Allocator = std::allocator\u0026lt;CharT\u003e \u003e\u003cbr\u003estd::basic_string\u0026lt;CharT, Traits, Allocator\u003e\u003cbr\u003e**to_string**( Allocator const \u0026 a = Allocator() ) const;|\n| to_string()           |\u003cC++11 | std::basic_string\u0026lt;CharT, Traits\u003e\u003cbr\u003e**to_string**() const;|\n| to_string()           |\u003cC++11 | template\u0026lt; class Allocator \u003e\u003cbr\u003estd::basic_string\u0026lt;CharT, Traits, Allocator\u003e\u003cbr\u003e**to_string**( Allocator const \u0026 a ) const;|\n| \u0026nbsp;                |\u0026nbsp; | \u0026nbsp; |\n| **Literal operator `sv`**|\u003e=C++11| macro `nssv_CONFIG_STD_SV_OPERATOR` |\n| \u0026nbsp;                |\u0026nbsp; | constexpr string_view operator \"\" **sv**( const char* str, size_t len ) noexcept; |\n| \u0026nbsp;                |\u0026nbsp; | constexpr u16string_view operator \"\" **sv**( const char16_t* str, size_t len ) noexcept; |\n| \u0026nbsp;                |\u0026nbsp; | constexpr u32string_view operator \"\" **sv**( const char32_t* str, size_t len ) noexcept; |\n| \u0026nbsp;                |\u0026nbsp; | constexpr wstring_view operator \"\" **sv**( const wchar_t* str, size_t len ) noexcept; |\n| \u0026nbsp;                |\u0026nbsp; | \u0026nbsp; |\n| **Literal operator `_sv`**|\u003e=C++11| macro `nssv_CONFIG_USR_SV_OPERATOR` |\n| \u0026nbsp;                |\u0026nbsp; | constexpr string_view operator \"\" **_sv**( const char* str, size_t len ) noexcept; |\n| \u0026nbsp;                |\u0026nbsp; | constexpr u16string_view operator \"\" **_sv**( const char16_t* str, size_t len ) noexcept; |\n| \u0026nbsp;                |\u0026nbsp; | constexpr u32string_view operator \"\" **_sv**( const char32_t* str, size_t len ) noexcept; |\n| \u0026nbsp;                |\u0026nbsp; | constexpr wstring_view operator \"\" **_sv**( const wchar_t* str, size_t len ) noexcept; |\n\n## Configuration\n\n### Tweak header\n\nIf the compiler supports [`__has_include()`](https://en.cppreference.com/w/cpp/preprocessor/include), *string-view lite* supports the [tweak header](https://vector-of-bool.github.io/2020/10/04/lib-configuration.html) mechanism. Provide your *tweak header* as `nonstd/string_view.tweak.hpp` in a folder in the include-search-path. In the tweak header, provide definitions as documented below, like `#define nssv_CONFIG_NO_EXCEPTIONS 1`.\n\n### Standard selection macro\n\n\\-D\u003cb\u003enssv\\_CPLUSPLUS\u003c/b\u003e=199711L  \nDefine this macro to override the auto-detection of the supported C++ standard, if your compiler does not set the `__cpluplus` macro correctly.\n\n### Select `std::string_view` or `nonstd::string_view`\n\nAt default, *string-view lite* uses `std::string_view` if it is available and lets you use it via namespace `nonstd`. You can however override this default and explicitly request to use `std::string_view` as `nonstd::string_view` or use string-view lite's `nonstd::string_view` via the following macros.\n\n-D\u003cb\u003enssv\\_CONFIG\\_SELECT\\_STRING_VIEW\u003c/b\u003e=nssv_STRING_VIEW_DEFAULT  \nDefine this to `nssv_STRING_VIEW_STD` to select `std::string_view` as `nonstd::string_view`. Define this to `nssv_STRING_VIEW_NONSTD` to select `nonstd::string_view` as `nonstd::string_view`. Default is undefined, which has the same effect as defining to `nssv_STRING_VIEW_DEFAULT`.\n\nNote: \u003cb\u003enssv_CONFIG_SELECT_STD_STRING_VIEW\u003c/b\u003e and \u003cb\u003enssv_CONFIG_SELECT_NONSTD_STRING_VIEW\u003c/b\u003e are deprecated and have been removed.\n\n### Disable exceptions\n\n-D\u003cb\u003enssv\\_CONFIG\\_NO\\_EXCEPTIONS\u003c/b\u003e=0\nDefine this to 1 if you want to compile without exceptions. If not defined, the header tries and detect if exceptions have been disabled (e.g. via `-fno-exceptions`). Default is undefined.\n\n### Add or omit literal operators `sv` and `_sv`\n\n-D\u003cb\u003enssv_CONFIG_STD_SV_OPERATOR\u003c/b\u003e=1  \nDefine this to 1 to provide literal operator `sv` to create a `string_view` from a literal string. Default is 0. Note that literal operators without leading underscore are reserved for the C++ standard.\n\n-D\u003cb\u003enssv_CONFIG_USR_SV_OPERATOR\u003c/b\u003e=0  \nDefine this to 0 to omit literal operator `_sv` to create a `string_view` from a literal string. Default is 1.\n\n### Omit cooperation between `std::string`\u0026ndash;`nonstd::string_view`\n\nAt default, *string-view lite* provides several methods and free functions to mimic the cooperation between `std::string` and  `nonstd::string_view` (or `std::string_view`) that exists in C++17. See section [Non-standard extensions](#non-standard-extensions). The following macros allow you to control the presence of these functions.\n \n-D\u003cb\u003enssv_CONFIG_CONVERSION_STD_STRING\u003c/b\u003e=1  \nDefine this to 1 to provide `std::string`\u0026ndash; `nonstd::string_view` interoperability via methods of `nonstd::basic_string_view` and free functions, define it to 0 to omit all said methods and functions. Default is undefined.\n\n-D\u003cb\u003enssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS\u003c/b\u003e=1  \nDefine this to 1 to provide `std::string`\u0026ndash; `nonstd::string_view` interoperability via methods of `nonstd::basic_string_view`, define it to 0 to omit all said methods. Default is undefined.\n\n-D\u003cb\u003enssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS\u003c/b\u003e=1  \nDefine this to 1 to provide `std::string`\u0026ndash; `nonstd::string_view` interoperability via free functions, define it to 0 to omit all said functions. This also controls the presence of these function if `std::string_view` is used. Default is undefined.\n\n### Omit use of streams\n\nAt default, *string-view lite* provides operations to overload the `operator\u003c\u003c`. If you want to use the library without the use of standard streams, you can control this with the following macro:\n\n-D\u003cb\u003enssv_CONFIG_NO_STREAM_INSERTION\u003c/b\u003e=1  \nDefine this to 1 to omit the use of standard streams. Default is undefined.\n\n### Avoid `constexpr` with `std::search()`\n\nAt default, *string-view lite* may use constexpr with `std::search()` for `string_view::find()` when compiling for C++11 or C++14, whereas `std::search()` is only constexpr since C++20. This may occur when macro `__OPTIMIZE__` is not defined and a non-recursive implementation for search is selected. Macro `__OPTIMIZE__` is used with GCC and clang.\n\nIf you encounter an error related to this, you can control this behaviour with the following macro:\n\n-D\u003cb\u003enssv_CONFIG_CONSTEXPR11_STD_SEARCH\u003c/b\u003e=0  \nDefine this to 0 to omit the use constexpr with `std::search()` and substitute a local implementation using `nssv_constexpr14`. Default is 1.\n\n### Enable compilation errors\n\n\\-D\u003cb\u003enssv\\_CONFIG\\_CONFIRMS\\_COMPILATION\\_ERRORS\u003c/b\u003e=0  \nDefine this macro to 1 to experience the by-design compile-time errors of the library in the test suite. Default is 0.\n\n## Reported to work with\n\nThe table below mentions the compiler versions *string-view lite* is reported to work with.\n\nOS        | Compiler   | Versions |\n---------:|:-----------|:---------|\nWindows   | Clang/LLVM | ?        |\n\u0026nbsp;    | GCC        | 7.2.0    |\n\u0026nbsp;    | Visual C++\u003cbr\u003e(Visual Studio)| 8 (2005), 9 (2008), 10 (2010), 11 (2012),\u003cbr\u003e12 (2013), 14 (2015), 15 (2017) |\nGNU/Linux | Clang/LLVM | 3.5 - 6.0  |\n\u0026nbsp;    | GCC        | 4.8 - 8 |\nOS X      | Clang/LLVM | Xcode 6, Xcode 7, Xcode 8, Xcode 9 |\n\n## Building the tests\n\nTo build the tests you need:\n\n- [CMake](http://cmake.org), version 3.0 or later to be installed and in your PATH.\n- A [suitable compiler](#reported-to-work-with).\n\nThe [*lest* test framework](https://github.com/martinmoene/lest) is included in the [test folder](test).\n\nThe following steps assume that the [*string-view lite* source code](https://github.com/martinmoene/string-view-lite) has been cloned into a directory named `c:\\string-view-lite`.\n\n1. Create a directory for the build outputs for a particular architecture.\nHere we use c:\\string-view-lite\\build-win-x86-vc10.\n\n        cd c:\\string-view-lite\n        md build-win-x86-vc10\n        cd build-win-x86-vc10\n\n2. Configure CMake to use the compiler of your choice (run `cmake --help` for a list).\n\n        cmake -G \"Visual Studio 10 2010\" -DSTRING_VIEW_LITE_OPT_BUILD_TESTS=ON ..\n\n3. Build the test suite in the Debug configuration (alternatively use Release).    \n\n        cmake --build . --config Debug\n\n4. Run the test suite.    \n\n        ctest -V -C Debug\n\nAll tests should pass, indicating your platform is supported and you are ready to use *string-view lite*.\n\n## Other implementations of string_view\n\n- Marshall Clow. [string_view implementation for libc++](https://github.com/mclow/string_view). GitHub.\n- LLVM libc++. [string_view](https://github.com/llvm/llvm-project/blob/main/libcxx/include/string_view). GitHub.\n- Matthew Rodusek's, @bitwizeshift. [string_view Standalone](https://github.com/bitwizeshift/string_view-standalone). GitHub.\n- @satoren. [string_view for C++03 C++11 C++14](https://github.com/satoren/string_view). GitHub.\n- Google Abseil [string_view](https://github.com/abseil/abseil-cpp/tree/master/absl/strings) (non-templated).\n- [Search _string view c++_ on GitHub](https://github.com/search?l=C%2B%2B\u0026q=string+view+c%2B%2B\u0026type=Repositories\u0026utf8=%E2%9C%93).\n\n## Notes and references\n\n*Interface and specification*\n\n- [string_view on cppreference](http://en.cppreference.com/w/cpp/string/basic_string_view).\n- [n4659 - C++17 Working Draft: string_view](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf#page=780).\n\n*Presentations*\n\n- Marshall Clow. [string_view - when to use it, and when not](https://cppcon2015.sched.com/event/3vch/stringview-when-to-use-it-and-when-not?iframe=yes\u0026w=700\u0026sidebar=yes\u0026bg=no#). CppCon 2015. [video](https://youtu.be/H9gAaNRoon4), [slides](https://github.com/CppCon/CppCon2015/blob/master/Presentations/string_view/string_view%20-%20Marshall%20Clow%20-%20CppCon%202015.pdf).\n- Neil MacIntosh. [A few good types: Evolving array_view and string_view for safe C++ code](https://cppcon2015.sched.com/event/3vbQ/a-few-good-types-evolving-arrayview-and-stringview-for-safe-c-code). CppCon 2015. [video](https://youtu.be/C4Z3c4Sv52U), [slides](https://github.com/CppCon/CppCon2015/blob/master/Presentations/A%20Few%20Good%20Types/A%20Few%20Good%20Types%20-%20Neil%20MacIntosh%20-%20CppCon%202015.pdf).\n\n*Proposals*\n\n- Jeffrey Yasskin. [n3334 - Proposing array_ref\u003cT\u003e and string_ref](https://wg21.link/n3334). 2012.\n- Jeffrey Yasskin. [n3921 - string_view: a non-owning reference to a string, revision 7](http://wg21.link/n3921). **Adopted 2014-02**.\n- Alisdair Meredith. [n4288 - Strike string_view::clear from Library Fundamentals](http://wg21.link/n4288). **Adopted 2014-11**.\n- Neil MacIntosh. [p0123 - Unifying the interfaces of string_view and array_view](http://wg21.link/p0123). 2015.\n- Beman Dawes, Alisdair Meredith. [p0220 - Adopt Library Fundamentals V1 TS Components for C++17 (R1)](https://wg21.link/p0220r1). 2016.\n- Marshall Clow. [p0254 - Integrating std::string_view and std::string](http://wg21.link/p0254). **Adopted 2016-06**.\n- Nicolai Josuttis. [p0392 - Adapting string_view by filesystem paths](https://wg21.link/p0392r0). 2016.\n- Marshall Clow. [p0403 - Literal suffixes for basic_string_view](http://wg21.link/p0403). 2016.\n- Peter Sommerlad. [p0506 - use string_view for library function parameters instead of const string \u0026/const char *](http://wg21.link/p0506). 2017.\n- Daniel Krugler. [wg2946 - LWG 2758's resolution missed further corrections](https://wg21.link/lwg2946). 2017.\n- Yuriy Chernyshov. [p2166 - A Proposal to Prohibit std::basic_string and std::basic_string_view construction from nullptr](https://wg21.link/p2166). 2020. **Adopted 2021-06**.\n\n## Appendix\n\n### A.1 Compile-time information\n\nThe version of *string-view lite* is available via tag `[.version]`. The following tags are available for information on the compiler and on the C++ standard library used: `[.compiler]`, `[.builtins]`, `[.stdc++]`, `[.stdlanguage]` and `[.stdlibrary]`.\n\n### A.2 string-view lite test specification\n\n\u003cdetails\u003e\n\u003csummary\u003eclick to expand\u003c/summary\u003e\n\u003cp\u003e\n\n```Text\nstring_view: Allows to default construct an empty string_view\nstring_view: Allows to construct from pointer and size\nstring_view: Allows to construct from C-string\nstring_view: Allows to copy-construct from empty string_view\nstring_view: Allows to copy-construct from non-empty string_view\nstring_view: Disallows to copy-construct from nullptr (C++11)\nstring_view: Disallows to copy-assign from nullptr (C++11)\nstring_view: Allows to copy-assign from empty string_view\nstring_view: Allows to copy-assign from non-empty string_view\nstring_view: Allows forward iteration\nstring_view: Allows const forward iteration\nstring_view: Allows reverse iteration\nstring_view: Allows const reverse iteration\nstring_view: Allows to obtain the size of the view via size()\nstring_view: Allows to obtain the size of the view via length()\nstring_view: Allows to obtain the maximum size a view can be via max_size()\nstring_view: Allows to check for an empty string_view via empty()\nstring_view: Allows to observe an element via array indexing\nstring_view: Allows to observe an element via at()\nstring_view: Throws at observing an element via at() with an index of size() or larger\nstring_view: Allows to observe elements via data()\nstring_view: Yields nullptr (or NULL) with data() for an empty string_view\nstring_view: Allows to remove a prefix of n elements\nstring_view: Allows to remove a suffix of n elements\nstring_view: Allows to swap with other string_view\nstring_view: Allows to copy a substring of length n, starting at position pos (default: 0) via copy()\nstring_view: Throws if requested position of copy() exceeds string_view's size()\nstring_view: Allow to obtain a sub string, starting at position pos (default: 0) and of length n (default full), via substr()\nstring_view: Throws if requested position of substr() exceeds string_view's size()\nstring_view: Allows to lexically compare to another string_view via compare(), (1)\nstring_view: Allows to compare empty string_views as equal via compare(), (1)\nstring_view: Allows to constexpr-compare string_views via compare(), (1) (C++14)\nstring_view: Allows to compare a sub string to another string_view via compare(), (2)\nstring_view: Allows to compare a sub string to another string_view sub string via compare(), (3)\nstring_view: Allows to compare to a C-string via compare(), (4)\nstring_view: Allows to compare a sub string to a C-string via compare(), (5)\nstring_view: Allows to compare a sub string to a C-string prefix via compare(), (6)\nstring_view: Allows to check for a prefix string_view via starts_with(), (1)\nstring_view: Allows to check for a prefix character via starts_with(), (2)\nstring_view: Allows to check for a prefix C-string via starts_with(), (3)\nstring_view: Allows to check for a suffix string_view via ends_with(), (1)\nstring_view: Allows to check for a suffix character via ends_with(), (2)\nstring_view: Allows to check for a suffix C-string via ends_with(), (3)\nstring_view: Allows to search for a string_view substring, starting at position pos (default: 0) via find(), (1)\nstring_view: Allows to search for a character, starting at position pos (default: 0) via find(), (2)\nstring_view: Allows to search for a C-string substring, starting at position pos and of length n via find(), (3)\nstring_view: Allows to search for a C-string substring, starting at position pos (default: 0) via find(), (4)\nstring_view: Allows to search backwards for a string_view substring, starting at position pos (default: npos) via rfind(), (1)\nstring_view: Allows to search backwards for a character, starting at position pos (default: npos) via rfind(), (2)\nstring_view: Allows to search backwards for a C-string substring, starting at position pos and of length n via rfind(), (3)\nstring_view: Allows to search backwards for a C-string substring, starting at position pos (default: 0) via rfind(), (4)\nstring_view: Allows to search for the first occurrence of any of the characters specified in a string view, starting at position pos (default: 0) via find_first_of(), (1)\nstring_view: Allows to search for a character, starting at position pos (default: 0) via find_first_of(), (2)\nstring_view: Allows to search for the first occurrence of any of the characters specified in a C-string, starting at position pos and of length n via find_first_of(), (3)\nstring_view: Allows to search for the first occurrence of any of the characters specified in a C-string, starting at position pos via find_first_of(), (4)\nstring_view: Allows to search backwards for the last occurrence of any of the characters specified in a string view, starting at position pos (default: npos) via find_last_of(), (1)\nstring_view: Allows to search backwards for a character, starting at position pos (default: 0) via find_last_of(), (2)\nstring_view: Allows to search backwards for the first occurrence of any of the characters specified in a C-string, starting at position pos and of length n via find_last_of(), (3)\nstring_view: Allows to search backwards for the first occurrence of any of the characters specified in a C-string, starting at position pos via find_last_of(), (4)\nstring_view: Allows to search for the first character not specified in a string view, starting at position pos (default: 0) via find_first_not_of(), (1)\nstring_view: Allows to search for the first character not equal to the specified character, starting at position pos (default: 0) via find_first_not_of(), (2)\nstring_view: Allows to search for  the first character not equal to any of the characters specified in a C-string, starting at position pos and of length n via find_first_not_of(), (3)\nstring_view: Allows to search for  the first character not equal to any of the characters specified in a C-string, starting at position pos via find_first_not_of(), (4)\nstring_view: Allows to search backwards for the first character not specified in a string view, starting at position pos (default: npos) via find_last_not_of(), (1)\nstring_view: Allows to search backwards for the first character not equal to the specified character, starting at position pos (default: npos) via find_last_not_of(), (2)\nstring_view: Allows to search backwards for  the first character not equal to any of the characters specified in a C-string, starting at position pos and of length n via find_last_not_of(), (3)\nstring_view: Allows to search backwards for  the first character not equal to any of the characters specified in a C-string, starting at position pos via find_last_not_of(), (4)\nstring_view: Allows to create a string_view, wstring_view, u16string_view, u32string_view via literal \"sv\"\nstring_view: Allows to create a string_view via literal \"sv\", using namespace nonstd::literals::string_view_literals\nstring_view: Allows to create a string_view via literal \"sv\", using namespace nonstd::string_view_literals\nstring_view: Allows to create a string_view via literal \"sv\", using namespace nonstd::literals\nstring_view: Allows to create a string_view, wstring_view, u16string_view, u32string_view via literal \"_sv\"\nstring_view: Allows to create a string_view via literal \"_sv\", using namespace nonstd::literals::string_view_literals\nstring_view: Allows to create a string_view via literal \"_sv\", using namespace nonstd::string_view_literals\nstring_view: Allows to create a string_view via literal \"_sv\", using namespace nonstd::literals\nstring_view: Allows to compare a string_view with another string_view via comparison operators\nstring_view: Allows to compare a string_view with an object with implicit conversion to string_view via comparison operators\nstring_view: Allows to compare empty string_view-s as equal via compare() and via operator==()\noperator\u003c\u003c: Allows printing a string_view to an output stream\nstd::hash\u003c\u003e: Hash value of string_view equals hash value of corresponding string object\nstd::hash\u003c\u003e: Hash value of wstring_view equals hash value of corresponding string object\nstd::hash\u003c\u003e: Hash value of u16string_view equals hash value of corresponding string object\nstd::hash\u003c\u003e: Hash value of u32string_view equals hash value of corresponding string object\nstring_view: construct from std::string [extension]\nstring_view: convert to std::string via explicit operator [extension]\nstring_view: convert to std::string via to_string() [extension]\nto_string(): convert to std::string via to_string() [extension]\nto_string_view(): convert from std::string via to_string_view() [extension]\ntweak header: reads tweak header if supported [tweak]\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n","funding_links":[],"categories":["Standard/Support Libraries","C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinmoene%2Fstring-view-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinmoene%2Fstring-view-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinmoene%2Fstring-view-lite/lists"}