1 #ifndef BOOST_ALGORITHM_RG071801_HPP
2 #define BOOST_ALGORITHM_RG071801_HPP
7 // Hewlett-Packard Company
9 // Permission to use, copy, modify, distribute and sell this software
10 // and its documentation for any purpose is hereby granted without fee,
11 // provided that the above copyright notice appear in all copies and
12 // that both that copyright notice and this permission notice appear
13 // in supporting documentation. Hewlett-Packard Company makes no
14 // representations about the suitability of this software for any
15 // purpose. It is provided "as is" without express or implied warranty.
18 // Copyright (c) 1996-1998
19 // Silicon Graphics Computer Systems, Inc.
21 // Permission to use, copy, modify, distribute and sell this software
22 // and its documentation for any purpose is hereby granted without fee,
23 // provided that the above copyright notice appear in all copies and
24 // that both that copyright notice and this permission notice appear
25 // in supporting documentation. Silicon Graphics makes no
26 // representations about the suitability of this software for any
27 // purpose. It is provided "as is" without express or implied warranty.
29 // Copyright (C) 2002 Ronald Garcia
31 // Permission to copy, use, sell and distribute this software is granted
32 // provided this copyright notice appears in all copies.
33 // Permission to modify the code and to distribute modified code is granted
34 // provided this copyright notice appears in all copies, and a notice
35 // that the code was modified is included with the copyright notice.
37 // This software is provided "as is" without express or implied warranty,
38 // and with no claim as to its suitability for any purpose.
42 #include "boost/iterator.hpp"
46 //--------------------------------------------------
47 // copy_n (not part of the C++ standard)
50 template <class InputIter, class Size, class OutputIter>
51 OutputIter copy_n(InputIter first, Size count,
53 for ( ; count > 0; --count) {
62 template <class InputIter, class Size, class OutputIter>
63 OutputIter copy_n__(InputIter first, Size count,
65 std::input_iterator_tag) {
66 for ( ; count > 0; --count) {
74 template <class RAIter, class Size, class OutputIter>
76 copy_n__(RAIter first, Size count,
78 std::random_access_iterator_tag) {
79 RAIter last = first + count;
80 return std::copy(first, last, result);
83 template <class InputIter, class Size, class OutputIter>
85 copy_n__(InputIter first, Size count, OutputIter result) {
86 typedef typename std::iterator_traits<InputIter>::iterator_category cat;
87 return copy_n__(first, count, result, cat());
90 template <class InputIter, class Size, class OutputIter>
92 copy_n(InputIter first, Size count, OutputIter result) {
93 return copy_n__(first, count, result);
100 #endif // BOOST_ALGORITHM_RG071801_HPP