bool operator==(T *rhs) const
Comparison with another pointer.
ContextSpecificData(T proto={})
Constructor with prototype value.
T accumulate(T init) const
Return the sum of all the contained values using init as first value.
T *& set(T *ptr)
Set the pointer for the current context.
ContextSpecificPtr< T > m_ptr
Internal implementation.
auto accumulate(Mapper f, std::invoke_result_t< Mapper, const T * > init) const -> decltype(init)
Taking a function f that from a T* produces a value, return the sum of all the values corresponding t...
std::mutex m_ptrs_lock
Mutex for the m_ptrs container.
T1 accumulate(T1 init, BinaryOperation op) const
Return the accumulated result, through the operation 'op', of all the contained values using init as ...
T & operator=(const T &other)
Assignment operator.
Simple implementation of a smart pointer with different values for different event contexts (slots).
void for_each(F f) const
Call a function on each contained value.
ContextSpecificData(const ContextSpecificData &)=delete
void for_all(F f) const
Call a function on each element, passing slot# as well.
StorageType m_ptrs
Internal storage for the different internal pointers.
void for_each(F f) const
Call a function on each contained pointer.
T * get() const
Return the pointer for the current context (null for a new context).
void for_all(F f) const
Call a function on each element, passing slot# as well.
std::unordered_map< ContextIdType, T * > StorageType
Type used for the internal storage.
void for_each(F f)
Call a function on each contained value. (non-const version)
const T * operator->() const
const T & operator*() const
Implementation of a context specific storage accessible as a sort of smart reference class.
bool isValid() const
Return true if the pointer is not null.
auto accumulate(Mapper f, std::invoke_result_t< Mapper, const T * > init, BinaryOperation op) const -> decltype(init)
Taking a function f that from a T* produces a value, return the accumulated result,...
void for_each(F f)
Call a function on each contained pointer. (non-const version)