Template Class ValuePtr

Class Documentation

template<typename T>
class ValuePtr

a wrapper around shared_ptr that has more value-like semantics while avoiding copies where possible

this should be used in ports (or structures moved through ports) to wrap things like ADM data which the user might want to modify in-place but are expensive to copy

the value can not be modified in-place, as this would be visible in other ‘copies’ of this structure

Public Functions

inline ValuePtr()
inline ValuePtr(std::shared_ptr<T> value_)
inline std::shared_ptr<const T> read() const

get read-only access to the value

inline std::shared_ptr<T> move_or_copy() const

get a non-const value that can be modified

this makes a copy if there are multiple users of the underlying value, or moves if there is only one