• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>copy_n</title>
5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../../../index.html" title="Chapter 1. Range 2.0">
8<link rel="up" href="../new.html" title="New algorithms">
9<link rel="prev" href="../new.html" title="New algorithms">
10<link rel="next" href="erase.html" title="erase">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="../new.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../new.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="erase.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h5 class="title">
27<a name="range.reference.algorithms.new.copy_n"></a><a class="link" href="copy_n.html" title="copy_n">copy_n</a>
28</h5></div></div></div>
29<h6>
30<a name="range.reference.algorithms.new.copy_n.h0"></a>
31            <span class="phrase"><a name="range.reference.algorithms.new.copy_n.prototype"></a></span><a class="link" href="copy_n.html#range.reference.algorithms.new.copy_n.prototype">Prototype</a>
32          </h6>
33<p>
34</p>
35<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">SinglePassRange</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Size</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">OutputIterator</span><span class="special">&gt;</span>
36<span class="identifier">OutputIterator</span> <span class="identifier">copy_n</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">SinglePassRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">,</span> <span class="identifier">Size</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">OutputIterator</span> <span class="identifier">out</span><span class="special">);</span>
37</pre>
38<p>
39          </p>
40<h6>
41<a name="range.reference.algorithms.new.copy_n.h1"></a>
42            <span class="phrase"><a name="range.reference.algorithms.new.copy_n.description"></a></span><a class="link" href="copy_n.html#range.reference.algorithms.new.copy_n.description">Description</a>
43          </h6>
44<p>
45            <code class="computeroutput"><span class="identifier">copy_n</span></code> is provided to
46            completely replicate the standard algorithm header, it is preferable
47            to use Range Adaptors and the extension functions to achieve the same
48            result with greater safety.
49          </p>
50<p>
51            <code class="computeroutput"><span class="identifier">copy_n</span></code> copies elements
52            from <code class="computeroutput"><span class="special">[</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">rng</span><span class="special">),</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">n</span><span class="special">)</span></code> to the range <code class="computeroutput"><span class="special">[</span><span class="identifier">out</span><span class="special">,</span> <span class="identifier">out</span> <span class="special">+</span> <span class="identifier">n</span><span class="special">)</span></code>
53          </p>
54<h6>
55<a name="range.reference.algorithms.new.copy_n.h2"></a>
56            <span class="phrase"><a name="range.reference.algorithms.new.copy_n.definition"></a></span><a class="link" href="copy_n.html#range.reference.algorithms.new.copy_n.definition">Definition</a>
57          </h6>
58<p>
59            Defined in the header file <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">range</span><span class="special">/</span><span class="identifier">algorithm_ext</span><span class="special">/</span><span class="identifier">copy_n</span><span class="special">.</span><span class="identifier">hpp</span></code>
60          </p>
61<h6>
62<a name="range.reference.algorithms.new.copy_n.h3"></a>
63            <span class="phrase"><a name="range.reference.algorithms.new.copy_n.requirements"></a></span><a class="link" href="copy_n.html#range.reference.algorithms.new.copy_n.requirements">Requirements</a>
64          </h6>
65<div class="orderedlist"><ol class="orderedlist" type="1">
66<li class="listitem">
67                <code class="computeroutput"><span class="identifier">SinglePassRange</span></code> is
68                a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
69                Pass Range</a> Concept.
70              </li>
71<li class="listitem">
72                <code class="computeroutput"><span class="identifier">Size</span></code> is a model of
73                the <code class="computeroutput"><span class="identifier">Integer</span></code> Concept.
74              </li>
75<li class="listitem">
76                <code class="computeroutput"><span class="identifier">OutputIterator</span></code> is
77                a model of the <code class="computeroutput"><span class="identifier">OutputIteratorConcept</span></code>.
78              </li>
79</ol></div>
80<h6>
81<a name="range.reference.algorithms.new.copy_n.h4"></a>
82            <span class="phrase"><a name="range.reference.algorithms.new.copy_n.complexity"></a></span><a class="link" href="copy_n.html#range.reference.algorithms.new.copy_n.complexity">Complexity</a>
83          </h6>
84<p>
85            Linear. Exactly <code class="computeroutput"><span class="identifier">n</span></code> elements
86            are copied.
87          </p>
88</div>
89<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
90<td align="left"></td>
91<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen,
92      Neil Groves<p>
93        Distributed under the Boost Software License, Version 1.0. (See accompanying
94        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
95      </p>
96</div></td>
97</tr></table>
98<hr>
99<div class="spirit-nav">
100<a accesskey="p" href="../new.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../new.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="erase.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
101</div>
102</body>
103</html>
104