[ Web Proxy ]
URL:
Viewing: http://ja.cppreference.com/cpp/string/basic_string_view/basic_string_view [Back]  [Original]

std::basic_string_view<CharT,Traits>::basic_string_view - cppreference.com
cppreference.com

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)
template<class It, class End> constexpr basic_string_view(It first, End last);
(5) (C++20)
1) basic_string_view data() nullptr size() 0
2) other data() other.data() size() other.size()
3) s count s [s, s+count) () data() s size() count
4) s Traits::length(s) [s, s+Traits::length(s)) data() s size() Traits::length(s)
5) [first, last) basic_string_view [first, last) It contiguous_iterator End It sized_sentinel_for data() std::to_address(first) size() last - first

other -
s - C
count -
first -
last -

1-3,5)
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


() [edit]

Web Proxy Viewer  |  New URL  |  Original Page