libstdc++
GNU C++ library
Loading...
Searching...
No Matches

◆ substr() [1/2]

template<typename _CharT, typename _Traits, typename _Alloc>
basic_string std::basic_string< _CharT, _Traits, _Alloc >::substr ( size_type __pos = 0,
size_type __n = npos ) const
inlinenodiscardconstexpr

Get a substring.

Parameters
__posIndex of first character (default 0).
__nNumber of characters in substring (default remainder).
Returns
The new string.
Exceptions
std::out_of_rangeIf __pos > size().

Construct and return a new string using the __n characters starting at __pos. If the string is too short, use the remainder of the characters. If __pos is beyond the end of the string, out_of_range is thrown.

Definition at line 3465 of file basic_string.h.

3466 { return basic_string(*this,
3467 _M_check(__pos, "basic_string::substr"), __n); }
constexpr basic_string() noexcept(/*conditional */)
Default constructor creates an empty string.
constexpr size_type _M_check(size_type __pos, const char *__s) const
Managing sequences of characters and character-like objects.

Referenced by __gnu_debug::basic_string< char >::substr().

Here is the caller graph for this function: