File indexing completed on 2025-01-18 09:10:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/EventData/SourceLink.hpp"
0012
0013 #include <ranges>
0014
0015 namespace Acts::detail {
0016
0017
0018 template <typename external_t>
0019 concept isCollectionThatSupportsPushBack =
0020 std::ranges::range<external_t> && requires {
0021 typename external_t::value_type;
0022 } && requires(external_t coll, typename external_t::value_type val) {
0023 coll.push_back(val);
0024 };
0025
0026 template <typename external_t>
0027 concept isCollectionThatSupportsInsert =
0028 std::ranges::range<external_t> && requires {
0029 typename external_t::value_type;
0030 } && requires(external_t coll, typename external_t::value_type val) {
0031 coll.insert(std::ranges::end(coll), val);
0032 };
0033
0034 template <typename grid_t>
0035 concept SourceLinkGrid =
0036 std::same_as<typename grid_t::value_type, std::vector<Acts::SourceLink>>;
0037
0038
0039 template <Acts::detail::isCollectionThatSupportsPushBack storage_t,
0040 typename value_t>
0041 requires requires(storage_t coll, value_t value) {
0042 coll.push_back(value);
0043 coll.push_back(std::move(value));
0044 }
0045 void pushBackOrInsertAtEnd(storage_t& storage, value_t&& value) {
0046 storage.push_back(std::forward<value_t>(value));
0047 }
0048
0049 template <std::ranges::range storage_t, typename value_t>
0050 requires(!Acts::detail::isCollectionThatSupportsPushBack<storage_t> &&
0051 Acts::detail::isCollectionThatSupportsInsert<storage_t> &&
0052 requires(storage_t coll, value_t value) {
0053 coll.insert(std::ranges::end(coll), value);
0054 coll.insert(std::ranges::end(coll), std::move(value));
0055 })
0056 void pushBackOrInsertAtEnd(storage_t& storage, value_t&& value) {
0057 storage.insert(std::ranges::end(storage), std::forward<value_t>(value));
0058 }
0059
0060 }