Technical Specification | ||||
Filesystem library(filesystem TS) | ||||
Library fundamentals(library fundamentals TS) | ||||
Library fundamentals 2(library fundamentals TS v2) | ||||
Library fundamentals 3(library fundamentals TS v3) | ||||
Extensions for parallelism(parallelism TS) | ||||
Extensions for parallelism 2(parallelism TS v2) | ||||
Extensions for concurrency(concurrency TS) | ||||
Extensions for concurrency 2(concurrency TS v2) | ||||
Concepts(concepts TS) | ||||
Ranges(ranges TS) | ||||
Reflection(reflection TS) | ||||
Mathematical special functions(special functions TR) | ||||
Experimental Non-TS | ||||
Pattern Matching | ||||
Linear Algebra | ||||
std::execution | ||||
Contracts | ||||
2D Graphics |
|
|
constexpr basic_string_view()noexcept; | (1) | (library fundamentals TS) |
constexpr basic_string_view(const basic_string_view& other)noexcept=default; | (2) | (library fundamentals TS) |
template<class Allocator> basic_string_view(conststd::basic_string<CharT, Traits, Allocator>& str)noexcept; | (3) | (library fundamentals TS) |
constexpr basic_string_view(const CharT* s, size_type count); | (4) | (library fundamentals TS) |
constexpr basic_string_view(const CharT* s); | (5) | (library fundamentals TS) |
basic_string_view
.[
s,
s+ count)
is not a valid range (even though the constructor may not access any of the elements of this range).[
s,
s+ Traits::length(s))
is not a valid range (even though the constructor may not access any of the elements of this range).Contents |
other | - | another view to initialize the view with |
str | - | a C++ string object to initialize view with |
s | - | pointer to a character array or a C string to initialize the view with |
count | - | number of characters to include in the view |
#include <experimental/string_view>#include <iostream> int main(){std::string cppstr="Foo";char array[3]={'B','a','r'}; std::experimental::string_view cppstr_v(cppstr);std::experimental::string_view array_v(array, sizeof array); std::experimental::wstring_view wcstr_v= L"xyzzy"; std::cout<< cppstr_v<<'\n'<< array_v<<'\n'<< wcstr_v.size()<<'\n';}
Output:
FooBar5
assigns a view (public member function)[edit] |