]> git.lyx.org Git - lyx.git/blob - boost/boost/multi_array/algorithm.hpp
Boost 1.31.0
[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 // Copyright 2002 The Trustees of Indiana University.
31
32 // Use, modification and distribution is subject to the Boost Software 
33 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
34 // http://www.boost.org/LICENSE_1_0.txt)
35
36 //  Boost.MultiArray Library
37 //  Authors: Ronald Garcia
38 //           Jeremy Siek
39 //           Andrew Lumsdaine
40 //  See http://www.boost.org/libs/multi_array for documentation.
41
42
43 #include "boost/iterator.hpp"
44
45 namespace boost {
46
47 //--------------------------------------------------
48 // copy_n (not part of the C++ standard)
49 #if 1
50
51 template <class InputIter, class Size, class OutputIter>
52 OutputIter copy_n(InputIter first, Size count,
53                   OutputIter result) {
54   for ( ; count > 0; --count) {
55     *result = *first;
56     ++first;
57     ++result;
58   }
59   return result;
60 }
61 #else // !1
62
63 template <class InputIter, class Size, class OutputIter>
64 OutputIter copy_n__(InputIter first, Size count,
65                                        OutputIter result,
66                                        std::input_iterator_tag) {
67   for ( ; count > 0; --count) {
68     *result = *first;
69     ++first;
70     ++result;
71   }
72   return result;
73 }
74
75 template <class RAIter, class Size, class OutputIter>
76 inline OutputIter
77 copy_n__(RAIter first, Size count,
78          OutputIter result,
79          std::random_access_iterator_tag) {
80   RAIter last = first + count;
81   return std::copy(first, last, result);
82 }
83
84 template <class InputIter, class Size, class OutputIter>
85 inline OutputIter
86 copy_n__(InputIter first, Size count, OutputIter result) {
87   typedef typename std::iterator_traits<InputIter>::iterator_category cat;
88   return copy_n__(first, count, result, cat());
89 }
90
91 template <class InputIter, class Size, class OutputIter>
92 inline OutputIter
93 copy_n(InputIter first, Size count, OutputIter result) {
94   return copy_n__(first, count, result);
95 }
96
97 #endif // 1
98
99 } // namespace boost
100
101 #endif // BOOST_ALGORITHM_RG071801_HPP