]> git.lyx.org Git - lyx.git/blob - boost/boost/multi_array/algorithm.hpp
2002-05-24 Lars Gullik Bj�nnes <larsbj@birdstep.com>
[lyx.git] / boost / boost / multi_array / algorithm.hpp
1 #ifndef BOOST_ALGORITHM_RG071801_HPP
2 #define BOOST_ALGORITHM_RG071801_HPP
3
4 //
5 //
6 // Copyright (c) 1994
7 // Hewlett-Packard Company
8 //
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.
16 //
17 //
18 // Copyright (c) 1996-1998
19 // Silicon Graphics Computer Systems, Inc.
20 //
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.
28 //
29
30 #include "boost/iterator.hpp"
31
32 namespace boost {
33
34 //--------------------------------------------------
35 // copy_n (not part of the C++ standard)
36 #if 1
37
38 template <class InputIter, class Size, class OutputIter>
39 OutputIter copy_n(InputIter first, Size count,
40                   OutputIter result) {
41   for ( ; count > 0; --count) {
42     *result = *first;
43     ++first;
44     ++result;
45   }
46   return result;
47 }
48 #else // !1
49
50 template <class InputIter, class Size, class OutputIter>
51 OutputIter copy_n__(InputIter first, Size count,
52                                        OutputIter result,
53                                        std::input_iterator_tag) {
54   for ( ; count > 0; --count) {
55     *result = *first;
56     ++first;
57     ++result;
58   }
59   return result;
60 }
61
62 template <class RAIter, class Size, class OutputIter>
63 inline OutputIter
64 copy_n__(RAIter first, Size count,
65          OutputIter result,
66          std::random_access_iterator_tag) {
67   RAIter last = first + count;
68   return std::copy(first, last, result);
69 }
70
71 template <class InputIter, class Size, class OutputIter>
72 inline 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());
76 }
77
78 template <class InputIter, class Size, class OutputIter>
79 inline OutputIter
80 copy_n(InputIter first, Size count, OutputIter result) {
81   return copy_n__(first, count, result);
82 }
83
84 #endif // 1
85
86 } // namespace boost
87
88 #endif // BOOST_ALGORITHM_RG071801_HPP