File indexing completed on 2025-01-18 09:11:11
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <utility>
0012
0013 namespace Acts::detail {
0014
0015
0016 template <typename T>
0017 struct RefHolder {
0018 T* ptr;
0019
0020 explicit RefHolder(T* _ptr) : ptr{_ptr} {}
0021 explicit RefHolder(T& ref) : ptr{&ref} {}
0022
0023 const T& operator*() const { return *ptr; }
0024 T& operator*() { return *ptr; }
0025
0026 const T* operator->() const { return ptr; }
0027 T* operator->() { return ptr; }
0028 };
0029
0030
0031
0032 template <typename T>
0033 struct ConstRefHolder {
0034 const T* ptr;
0035
0036 explicit ConstRefHolder(const T* _ptr) : ptr{_ptr} {}
0037 explicit ConstRefHolder(const T& ref) : ptr{&ref} {}
0038
0039 const T& operator*() const { return *ptr; }
0040
0041 const T* operator->() const { return ptr; }
0042 };
0043
0044
0045 template <typename T>
0046 struct ValueHolder {
0047 T val;
0048
0049
0050
0051 ValueHolder(T& _val) = delete;
0052
0053
0054
0055 ValueHolder(T&& _val) : val{std::move(_val)} {}
0056
0057
0058
0059 const T& operator*() const { return val; }
0060 T& operator*() { return val; }
0061
0062 const T* operator->() const { return &val; }
0063 T* operator->() { return &val; }
0064 };
0065
0066 }