std::basic_string<CharT,Traits,Allocator>::copy
cppreference.com
<tbody>
</tbody>
<tbody class="t-dcl-rev ">
</tbody><tbody>
</tbody>
size_type copy( CharT* dest, size_type count, size_type pos = 0 ) const; |
( C++20) | |
constexpr size_type copy( CharT* dest, size_type count, size_type pos = 0 ) const; |
( C++20) | |
[pos, pos + count) , dest. count == npos, [pos, size()).
.
| dest | ||
| count | ||
| pos | , |
.
std::out_of_range, pos > size().
count.
#include <iostream>
#include <string>
int main()
{
std::string foo("WINE");
// 0,
//
char bar[4]{};
// ,
foo.copy(bar, sizeof bar - 1);
std::cout << bar << '\n'; // , bar
}
:
WIN
C++:
| LWG 847 | C++98 |
| (public -) | |
(C++17) |
(public - std::basic_string_view<CharT,Traits>)
|
(C++11) |
( ) |
| () |