|
|
|||
File indexing completed on 2026-04-08 07:46:55
0001 // This file is part of the ACTS project. 0002 // 0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project 0004 // 0005 // This Source Code Form is subject to the terms of the Mozilla Public 0006 // License, v. 2.0. If a copy of the MPL was not distributed with this 0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/. 0008 0009 #pragma once 0010 0011 #include <ranges> 0012 0013 namespace Acts::Ranges { 0014 0015 /// Adaptor for converting a range to a container 0016 /// @tparam Container the container type to convert to 0017 template <template <typename...> class Container> 0018 struct to_adaptor { 0019 /// Convert a range to a container 0020 /// @tparam Range the range type to convert 0021 /// @param range the range to convert 0022 /// @return the converted container 0023 template <typename Range> 0024 auto operator()(Range&& range) const { 0025 using ValueType = std::ranges::range_value_t<Range>; 0026 return Container<ValueType>(std::ranges::begin(range), 0027 std::ranges::end(range)); 0028 } 0029 }; 0030 0031 /// Overload operator| for piping 0032 /// @tparam Range the range type to convert 0033 /// @tparam Container the container type to convert to 0034 /// @param range the range to convert 0035 /// @param adaptor the adaptor to use 0036 /// @return the converted container 0037 template <typename Range, template <typename...> class Container> 0038 auto operator|(Range&& range, to_adaptor<Container> adaptor) { 0039 return adaptor(std::forward<Range>(range)); 0040 } 0041 0042 /// Create the adaptor objects 0043 /// @tparam Container the container type to convert to 0044 /// @return the adaptor object 0045 template <template <typename...> class Container> 0046 inline constexpr to_adaptor<Container> to{}; 0047 0048 } // namespace Acts::Ranges
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|