📄 copy.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org"> <title>copy</title> <link href="../cppreference.css" rel="stylesheet" type="text/css"></head><body><table> <tr> <td> <div class="body-content"> <div class="header-box"> <a href="../index.html">cppreference.com</a> > <a href= "index.html">C++ Algorithms</a> > <a href="copy.html">copy</a> </div> <div class="name-format"> copy </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <algorithm> iterator copy( iterator start, iterator end, iterator dest );</pre> <p>The copy() function copies the elements between <em>start</em> and <em>end</em> to <em>dest</em>. In other words, after copy() has run,</p> <pre class="example-code"> *dest == *start *(dest+1) == *(start+1) *(dest+2) == *(start+2) ... *(dest+N) == *(start+N) </pre> <p>The return value is an iterator to the last element copied. copy() runs in <a href="../complexity.html">linear time</a>.</p> <p>For example, the following code uses copy() to copy the contents of one vector to another:</p> <pre class="example-code"> vector<int> from_vector; for( int i = 0; i < 10; i++ ) { from_vector.push_back( i ); } vector<int> to_vector(10); copy( from_vector.begin(), from_vector.end(), to_vector.begin() ); cout << "to_vector contains: "; for( unsigned int i = 0; i < to_vector.size(); i++ ) { cout << to_vector[i] << " "; } cout << endl; </pre> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="copy_backward.html">copy_backward</a><br> <a href="copy_n.html">copy_n</a><br> <a href="generate.html">generate</a><br> <a href="remove_copy.html">remove_copy</a><br> <a href="swap.html">swap</a><br> <a href="transform.html">transform</a> </div> </div> </td> </tr> </table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -