std::basic_string_view<CharT,Traits>::basic_string_view
cppreference.com
<tbody>
</tbody>
constexpr basic_string_view() noexcept; |
(1) | ( C++17) |
constexpr basic_string_view(const basic_string_view& other) noexcept = default; |
(2) | ( C++17) |
constexpr basic_string_view(const CharT* s, size_type count); |
(3) | ( C++17) |
constexpr basic_string_view(const CharT* s); |
(4) | ( C++17) |
1) -.
basic_string_view. data() nullptr, size() 0.2) .
other. data() other.data(), size() other.size().3)
count , s. s \0 . , [s, s+count) ( ). data() s, size() count.4)
s, \0, \0 . Traits::length(s). , [s, s+Traits::length(s)) . , data() s, size() Traits::length(s).| other | ||
| s | - | |
| count |
1-3)
4) ,
s#include <iostream>
#include <string>
#include <string_view>
int main()
{
std::wstring_view wcstr_v = L"xyzzy";
char array[3] = {'B', 'a', 'r'};
std::string_view array_v(array, std::size(array));
std::string cppstr = "Foo";
std::string_view cppstr_v(cppstr);
std::cout << cppstr_v << '\n'
<< array_v << '\n'
<< wcstr_v.size() << '\n';
}
:
Foo
Bar
5
(C++17) |
(public -) |