ATLAS Offline Software
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-2023 CERN for the benefit of the ATLAS collaboration
4 */
13 #ifndef CXXUTILS_COPY_BOUNDED_H
14 #define CXXUTILS_COPY_BOUNDED_H
15 
16 
17 #include "CxxUtils/concepts.h"
18 #include <iterator>
19 #include <algorithm>
20 
21 
22 namespace CxxUtils {
23 
24 
28 template <class InputIterator, class OutputIterator,
29  class InputTag, class OutputTag>
30 inline
31 OutputIterator
32 copy_bounded1 (InputIterator begi, InputIterator endi,
33  OutputIterator bego, OutputIterator endo,
34  const InputTag&,
35  const OutputTag&)
36 {
37  while (begi != endi && bego != endo) {
38  *bego = *begi;
39  ++begi;
40  ++bego;
41  }
42  return bego;
43 }
44 
45 
49 template <class InputIterator, class OutputIterator>
50 inline
51 OutputIterator
52 copy_bounded1 (InputIterator begi, InputIterator endi,
53  OutputIterator bego, OutputIterator endo,
54  const std::random_access_iterator_tag&,
55  const std::random_access_iterator_tag&)
56 {
57  size_t n = std::min (endi-begi, endo-bego);
58  return std::copy (begi, begi+n, bego);
59 }
60 
61 
76 template <class InputIterator, class OutputIterator>
77 ATH_REQUIRES( std::input_iterator<InputIterator> &&
78  std::output_iterator<OutputIterator,
79  typename std::iterator_traits<InputIterator>::value_type> )
80 inline
81 OutputIterator
82 copy_bounded (InputIterator begi, InputIterator endi,
83  OutputIterator bego, OutputIterator endo)
84 {
85  return copy_bounded1
86  (begi, endi, bego, endo,
87  typename std::iterator_traits<InputIterator>::iterator_category(),
88  typename std::iterator_traits<OutputIterator>::iterator_category());
89 }
90 
91 
99 template <class InputRange, class OutputRange>
100 inline
101 auto
102 copy_bounded (const InputRange& input, OutputRange& output)
103  -> decltype (std::begin(output))
104 {
105  return copy_bounded
108 }
109 
110 
121 template <class InputRange, class OutputRange>
122 inline
123 auto
124 copy_bounded (const InputRange& input, OutputRange&& output)
125  -> decltype (std::begin(output))
126 {
127  return copy_bounded
130 }
131 
132 
133 } // namespace CxxUtils
134 
135 
136 
137 #endif // not CXXUTILS_COPY_BOUNDED_H
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
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:32
beamspotman.n
n
Definition: beamspotman.py:731
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
CxxUtils
Definition: aligned_vector.h:29
CxxUtils::bego
InputIterator OutputIterator bego
Definition: copy_bounded.h:83
min
#define min(a, b)
Definition: cfImp.cxx:40
merge.output
output
Definition: merge.py:17
CxxUtils::endi
InputIterator endi
Definition: copy_bounded.h:82
concepts.h
Compatibility helpers for using some pieces of C++20 concepts with older compilers.
CxxUtils::endo
InputIterator OutputIterator OutputIterator endo
Definition: copy_bounded.h:84
CxxUtils::ATH_REQUIRES
ATH_REQUIRES(detail::IsConcurrentHashmapPayload< KEY > &&detail::IsConcurrentHashmapPayload< VALUE > &&detail::IsUpdater< UPDATER > &&detail::IsHash< HASHER, KEY > &&detail::IsBinaryPredicate< MATCHER, KEY >) class ConcurrentMap
Hash map from integers/pointers allowing concurrent, lockless reads.
Definition: ConcurrentMap.h:94
CxxUtils::copy_bounded
auto copy_bounded(const InputRange &input, OutputRange &output) -> decltype(std::begin(output))
Copy a range with bounds restriction.
Definition: copy_bounded.h:102
calibdata.copy
bool copy
Definition: calibdata.py:27