ATLAS Offline Software
range_with_conv.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  */
13 #ifndef CXXUTILS_RANGE_WITH_CONV_H
14 #define CXXUTILS_RANGE_WITH_CONV_H
15 
16 
17 #include <ranges>
18 #include <vector>
19 
20 
21 namespace CxxUtils {
22 
23 
27 template <class RANGE>
29  : public RANGE
30 {
31 public:
32  using RANGE::RANGE;
33  using Elt_t = std::ranges::range_value_t<RANGE>;
34 
35 
39  template <template <class, class> class CONT, class ALLOC>
40  operator CONT<Elt_t, ALLOC>() const
41  {
42  return CONT<Elt_t, ALLOC> (this->begin(), this->end());
43  }
44 
45 
49  std::vector<Elt_t> asVector() const
50  {
51  return *this;
52  }
53 };
54 
55 
56 // Stand-alone begin/end functions, findable by ADL.
57 // Needed to work around issues seen when root 6.30.04 is used with gcc14.
58 template <class T>
59 auto begin (range_with_conv<T>& s) { return s.begin(); }
60 template <class T>
61 auto begin (const range_with_conv<T>& s) { return s.begin(); }
62 template <class T>
63 auto end (range_with_conv<T>& s) { return s.end(); }
64 template <class T>
65 auto end (const range_with_conv<T>& s) { return s.end(); }
66 
67 
68 } // namespace CxxUtils
69 
70 
71 #endif // not CXXUTILS_RANGE_WITH_CONV_H
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
CxxUtils::range_with_conv::asVector
std::vector< Elt_t > asVector() const
Explicit conversion to a vector.
Definition: range_with_conv.h:49
CxxUtils
Definition: aligned_vector.h:29
CxxUtils::end
auto end(range_with_at< T > &s)
Definition: range_with_at.h:68
CxxUtils::range_with_conv
Add to a range class conversions to containers.
Definition: range_with_conv.h:30
CxxUtils::range_with_conv::Elt_t
std::ranges::range_value_t< RANGE > Elt_t
Definition: range_with_conv.h:33
CxxUtils::begin
auto begin(range_with_at< T > &s)
Definition: range_with_at.h:64