ATLAS Offline Software
Loading...
Searching...
No Matches
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 */
11
12
13#ifndef CXXUTILS_RANGE_WITH_CONV_H
14#define CXXUTILS_RANGE_WITH_CONV_H
15
16
17#include <ranges>
18#include <vector>
19
20
21namespace CxxUtils {
22
23
27template <class RANGE>
29 : public RANGE
30{
31public:
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.
58template <class T>
59auto begin (range_with_conv<T>& s) { return s.begin(); }
60template <class T>
61auto begin (const range_with_conv<T>& s) { return s.begin(); }
62template <class T>
63auto end (range_with_conv<T>& s) { return s.end(); }
64template <class T>
65auto 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
Add to a range class conversions to containers.
std::vector< Elt_t > asVector() const
Explicit conversion to a vector.
std::ranges::range_value_t< typename AuxDataTraits< Payload_t >::const_span > Elt_t
auto end(range_with_at< T > &s)
auto begin(range_with_at< T > &s)