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.
30 #include "boost/iterator.hpp"
34 //--------------------------------------------------
35 // copy_n (not part of the C++ standard)
38 template <class InputIter, class Size, class OutputIter>
39 OutputIter copy_n(InputIter first, Size count,
41 for ( ; count > 0; --count) {
50 template <class InputIter, class Size, class OutputIter>
51 OutputIter copy_n__(InputIter first, Size count,
53 std::input_iterator_tag) {
54 for ( ; count > 0; --count) {
62 template <class RAIter, class Size, class OutputIter>
64 copy_n__(RAIter first, Size count,
66 std::random_access_iterator_tag) {
67 RAIter last = first + count;
68 return std::copy(first, last, result);
71 template <class InputIter, class Size, class OutputIter>
73 copy_n__(InputIter first, Size count, OutputIter result) {
74 typedef std::iterator_traits<InputIter>::iterator_category cat;
75 return copy_n__(first, count, result, cat());
78 template <class InputIter, class Size, class OutputIter>
80 copy_n(InputIter first, Size count, OutputIter result) {
81 return copy_n__(first, count, result);
88 #endif // BOOST_ALGORITHM_RG071801_HPP