##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::experimental::basic_string_view::basic_string_view

From cppreference.com
< cpp‎ | experimental‎ | basic string view

constexpr basic_string_view(); | (1) | (library fundamentals TS)
constexpr basic_string_view(const basic_string_view& other) =default; | (2) | (library fundamentals TS)
template<class Allocator> basic_string_view(const basic_string<CharT, Traits, Allocator>& str); | (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)

1) Default constructor. Constructs an empty `basic_string_view`.
2) Copy constructor. Constructs a view of the same content of `other`.
3) Constructs a view of `str`.
4) Constructs a view of the first `count` characters of character string pointed to by `s`. `s` can contain null characters. The behavior is undefined if `s` does not point to an array of at least `count` elements of `CharT`.
5) Constructs a view of the null-terminated character string pointed to by `s`. The length of the view is determined by the first null character. The behavior is undefined if `s` does not point to an array of at least Traits::length(s)+1 elements of `CharT`.

### [edit] Parameters

other | - | another view to initialize the view with
str | - | string to initialize view with
s | - | pointer to a character string to initialize the view with
count | - | size of the resulting view

### [edit] Exceptions

1-3)
`noexcept` specification:
noexcept

### [edit] Complexity

1-4) constant

5) linear in length of `s`

### [edit] See also

operator= | assigns a view (public member function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/experimental/basic_string_view/basic_string_view&oldid=71136"
Category:

- unconditionally noexcept