fix doc example typo
[boost.git] / boost / multi_array / algorithm.hpp
blobc749c3f974715cc63bcaf393bf49cf98b10bccc8
1 #ifndef BOOST_ALGORITHM_RG071801_HPP
2 #define BOOST_ALGORITHM_RG071801_HPP
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.
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 // Copyright 2002 The Trustees of Indiana University.
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)
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.
43 #include "boost/iterator.hpp"
45 namespace boost {
46 namespace detail {
47 namespace multi_array {
48 //--------------------------------------------------
49 // copy_n (not part of the C++ standard)
50 #if 1
52 template <class InputIter, class Size, class OutputIter>
53 OutputIter copy_n(InputIter first, Size count,
54 OutputIter result) {
55 for ( ; count > 0; --count) {
56 *result = *first;
57 ++first;
58 ++result;
60 return result;
62 #else // !1
64 template <class InputIter, class Size, class OutputIter>
65 OutputIter copy_n__(InputIter first, Size count,
66 OutputIter result,
67 std::input_iterator_tag) {
68 for ( ; count > 0; --count) {
69 *result = *first;
70 ++first;
71 ++result;
73 return result;
76 template <class RAIter, class Size, class OutputIter>
77 inline OutputIter
78 copy_n__(RAIter first, Size count,
79 OutputIter result,
80 std::random_access_iterator_tag) {
81 RAIter last = first + count;
82 return std::copy(first, last, result);
85 template <class InputIter, class Size, class OutputIter>
86 inline OutputIter
87 copy_n__(InputIter first, Size count, OutputIter result) {
88 typedef typename std::iterator_traits<InputIter>::iterator_category cat;
89 return copy_n__(first, count, result, cat());
92 template <class InputIter, class Size, class OutputIter>
93 inline OutputIter
94 copy_n(InputIter first, Size count, OutputIter result) {
95 return copy_n__(first, count, result);
98 #endif // 1
99 } // namespace multi_array
100 } // namespace detail
101 } // namespace boost
103 #endif // BOOST_ALGORITHM_RG071801_HPP