File indexing completed on 2025-01-18 09:11:07
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <tuple>
0012 #include <type_traits>
0013
0014 namespace Acts::detail {
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 template <typename... extensions_t>
0025 struct Extendable {
0026
0027 static_assert((std::is_default_constructible_v<extensions_t> && ...),
0028 "all extensions must be default constructible");
0029 static_assert((std::is_copy_constructible_v<extensions_t> && ...),
0030 "all extensions must be copy constructible");
0031 static_assert((std::is_move_constructible_v<extensions_t> && ...),
0032 "all extensions must be move constructible");
0033
0034
0035
0036 Extendable() = default;
0037
0038
0039 Extendable(const Extendable<extensions_t...>& extendable) = default;
0040
0041
0042 Extendable(Extendable<extensions_t...>&& extendable) noexcept = default;
0043
0044
0045
0046
0047 Extendable(const std::tuple<extensions_t...>& extensions)
0048 : m_extensions(extensions) {}
0049
0050
0051
0052
0053 Extendable(std::tuple<extensions_t...>&& extensions)
0054 : m_extensions(std::move(extensions)) {}
0055
0056
0057
0058
0059 Extendable<extensions_t...>& operator=(
0060 const Extendable<extensions_t...>& extendable) = default;
0061
0062
0063
0064
0065 Extendable<extensions_t...>& operator=(
0066 Extendable<extensions_t...>&& extendable) noexcept = default;
0067
0068
0069
0070
0071
0072
0073 template <typename... appendices_t>
0074 Extendable<extensions_t..., appendices_t...> append(
0075 appendices_t... aps) const {
0076 auto catTuple =
0077 std::tuple_cat(m_extensions, std::tuple<appendices_t...>(aps...));
0078 return Extendable<extensions_t..., appendices_t...>(std::move(catTuple));
0079 }
0080
0081
0082
0083
0084 template <typename extension_t>
0085 const extension_t& get() const {
0086 return std::get<extension_t>(m_extensions);
0087 }
0088
0089
0090
0091
0092 template <typename extension_t>
0093 extension_t& get() {
0094 return std::get<extension_t>(m_extensions);
0095 }
0096
0097
0098
0099
0100 const std::tuple<extensions_t...>& tuple() const { return m_extensions; }
0101
0102
0103
0104
0105 std::tuple<extensions_t...>& tuple() { return m_extensions; }
0106
0107 private:
0108 std::tuple<extensions_t...> m_extensions;
0109 };
0110
0111 }