std::basic_string<CharT,Traits,Allocator>::copy (3) - Linux Manuals
std::basic_string<CharT,Traits,Allocator>::copy: std::basic_string<CharT,Traits,Allocator>::copy
NAME
std::basic_string<CharT,Traits,Allocator>::copy - std::basic_string<CharT,Traits,Allocator>::copy
Synopsis
size_type copy( CharT* dest,
size_type count,
size_type pos = 0) const;
Copies a substring [pos, pos+count) to character string pointed to by dest. If the requested substring lasts past the end of the string, or if count == npos, the copied substring is [pos, size()). The resulting character string is not null-terminated.
If pos > size(), std::out_of_range is thrown.
Parameters
dest - pointer to the destination character string
pos - position of the first character to include
count - length of the substring
Return value
number of characters copied
Exceptions
std::out_of_range if pos > size().
Complexity
linear in count
Example
// Run this code
Output:
See also
substr (public member function)