source: XIOS/dev/dev_olga/src/extern/boost/include/boost/multi_array/algorithm.hpp @ 1022

Last change on this file since 1022 was 1022, checked in by mhnguyen, 7 years ago
File size: 3.1 KB
Line 
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
45namespace boost {
46namespace detail {
47namespace multi_array {
48//--------------------------------------------------
49// copy_n (not part of the C++ standard)
50#if 1
51
52template <class InputIter, class Size, class OutputIter>
53OutputIter copy_n(InputIter first, Size count,
54                  OutputIter result) {
55  for ( ; count > 0; --count) {
56    *result = *first;
57    ++first;
58    ++result;
59  }
60  return result;
61}
62#else // !1
63
64template <class InputIter, class Size, class OutputIter>
65OutputIter 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;
72  }
73  return result;
74}
75
76template <class RAIter, class Size, class OutputIter>
77inline OutputIter
78copy_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);
83}
84
85template <class InputIter, class Size, class OutputIter>
86inline OutputIter
87copy_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());
90}
91
92template <class InputIter, class Size, class OutputIter>
93inline OutputIter
94copy_n(InputIter first, Size count, OutputIter result) {
95  return copy_n__(first, count, result);
96}
97
98#endif // 1
99} // namespace multi_array
100} // namespace detail
101} // namespace boost
102
103#endif // BOOST_ALGORITHM_RG071801_HPP
Note: See TracBrowser for help on using the repository browser.