ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
CxxUtils
CxxUtils
copy_bounded.h
Go to the documentation of this file.
1
// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
/*
3
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4
*/
11
12
13
#ifndef CXXUTILS_COPY_BOUNDED_H
14
#define CXXUTILS_COPY_BOUNDED_H
15
16
17
#include <iterator>
18
#include <algorithm>
19
20
21
namespace
CxxUtils
{
22
23
27
template
<
class
InputIterator,
class
OutputIterator,
28
class
InputTag,
class
OutputTag>
29
inline
30
OutputIterator
31
copy_bounded1
(InputIterator begi, InputIterator endi,
32
OutputIterator bego, OutputIterator endo,
33
const
InputTag&,
34
const
OutputTag&)
35
{
36
while
(begi != endi && bego != endo) {
37
*bego = *begi;
38
++begi;
39
++bego;
40
}
41
return
bego;
42
}
43
44
48
template
<
class
InputIterator,
class
OutputIterator>
49
inline
50
OutputIterator
51
copy_bounded1
(InputIterator begi, InputIterator endi,
52
OutputIterator bego, OutputIterator endo,
53
const
std::random_access_iterator_tag&,
54
const
std::random_access_iterator_tag&)
55
{
56
size_t
n = std::min (endi-begi, endo-bego);
57
return
std::copy (begi, begi+n, bego);
58
}
59
60
75
template
<std::input_iterator InputIterator,
76
std::output_iterator<typename std::iterator_traits<InputIterator>::value_type> OutputIterator>
77
inline
78
OutputIterator
79
copy_bounded
(InputIterator begi, InputIterator endi,
80
OutputIterator bego, OutputIterator endo)
81
{
82
return
copy_bounded1
83
(begi, endi, bego, endo,
84
typename
std::iterator_traits<InputIterator>::iterator_category(),
85
typename
std::iterator_traits<OutputIterator>::iterator_category());
86
}
87
88
96
template
<
class
InputRange,
class
OutputRange>
97
inline
98
auto
99
copy_bounded
(
const
InputRange& input, OutputRange& output)
100
->
decltype
(std::begin(output))
101
{
102
return
copy_bounded
103
(std::begin(input), std::end(input),
104
std::begin(output), std::end(output));
105
}
106
107
118
template
<
class
InputRange,
class
OutputRange>
119
inline
120
auto
121
copy_bounded
(
const
InputRange& input, OutputRange&& output)
122
->
decltype
(std::begin(output))
123
{
124
return
copy_bounded
125
(std::begin(input), std::end(input),
126
std::begin(output), std::end(output));
127
}
128
129
130
}
// namespace CxxUtils
131
132
133
134
#endif
// not CXXUTILS_COPY_BOUNDED_H
CxxUtils
Definition
aligned_vector.h:29
CxxUtils::copy_bounded
OutputIterator copy_bounded(InputIterator begi, InputIterator endi, OutputIterator bego, OutputIterator endo)
Copy a range with bounds restriction.
Definition
copy_bounded.h:79
CxxUtils::copy_bounded1
OutputIterator copy_bounded1(InputIterator begi, InputIterator endi, OutputIterator bego, OutputIterator endo, const InputTag &, const OutputTag &)
Copy a range with bounds restriction; generic version.
Definition
copy_bounded.h:31
Generated on
for ATLAS Offline Software by
1.17.0