ATLAS Offline Software
Loading...
Searching...
No Matches
ranges.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-2024 CERN for the benefit of the ATLAS collaboration.
4 */
13
14
15#ifndef CXXUTILS_RANGES_H
16#define CXXUTILS_RANGES_H
17
18
19#include <ranges>
20
21
22namespace CxxUtils {
23
24
26template <class RANGE, class T>
28 std::ranges::input_range<RANGE> &&
29 std::convertible_to<std::ranges::range_value_t<RANGE>, T>;
30
31
32#if __cpp_lib_ranges_to_container
33// If we're using C++23, just take the library version.
34using std::ranges::to;
35#else
36
37// Simplified version of C++23 to().
38template <class CONT, class RANGE>
39CONT to (RANGE&& r)
40{
41 return CONT (std::ranges::begin (r), std::ranges::end (r));
42}
43
44#endif
45
46} // namespace CxxUtils
47
48
49#endif // not CXXUTILS_RANGES_H
Concept for an input range over a given type.
Definition ranges.h:27
int r
Definition globals.cxx:22
CONT to(RANGE &&r)
Definition ranges.h:39