41template<
typename Derived>
47 static_assert(std::is_base_of<CRTP, Derived>::value
48 ,
"Derived must be derived from CRTP (as the name suggests)!");
50 return *
static_cast<Derived*
>(
this);
102 template<
typename... Args>
105 , _old(std::forward<Args>(args)...)
110 template<
typename Arg>
117 _old = std::move(_current);
118 return _current = std::forward<Arg>(arg);
121 const T&
get()
const {
return _current; }
122 const T&
old()
const {
return _old; }
125 operator const T&()
const {
return this->
get(); }
132 BlockParameter& operator+=(
const T& rhs) { _current += rhs;
return *
this; }
133 BlockParameter& operator-=(
const T& rhs) { _current -= rhs;
return *
this; }
134 BlockParameter& operator*=(
const T& rhs) { _current *= rhs;
return *
this; }
135 BlockParameter& operator/=(
const T& rhs) { _current /= rhs;
return *
this; }
136 BlockParameter& operator%=(
const T& rhs) { _current %= rhs;
return *
this; }
137 BlockParameter& operator&=(
const T& rhs) { _current &= rhs;
return *
this; }
138 BlockParameter& operator|=(
const T& rhs) { _current |= rhs;
return *
this; }
139 BlockParameter& operator<<=(
const T& rhs){ _current <<= rhs;
return *
this; }
140 BlockParameter& operator>>=(
const T& rhs){ _current >>= rhs;
return *
this; }
144 T operator++(
int) {
return _current++; }
145 T operator--(
int) {
return _current--; }
154#define APF_BLOCKPARAMETER_BOTH_PROXY_OPERATORS(opstring) \
155 friend bool operator opstring(const both_proxy& lhs, const T& rhs) { \
156 return lhs._p.get() opstring rhs && lhs._p.old() opstring rhs; } \
157 friend bool operator opstring(const T& lhs, const both_proxy& rhs) { \
158 return lhs opstring rhs._p.get() && lhs opstring rhs._p.old(); }
160 APF_BLOCKPARAMETER_BOTH_PROXY_OPERATORS(==)
161 APF_BLOCKPARAMETER_BOTH_PROXY_OPERATORS(!=)
162 APF_BLOCKPARAMETER_BOTH_PROXY_OPERATORS(<)
163 APF_BLOCKPARAMETER_BOTH_PROXY_OPERATORS(>)
164 APF_BLOCKPARAMETER_BOTH_PROXY_OPERATORS(<=)
165 APF_BLOCKPARAMETER_BOTH_PROXY_OPERATORS(>=)
166#undef APF_BLOCKPARAMETER_BOTH_PROXY_OPERATORS
174 both_proxy both()
const {
return both_proxy(*
this); }
177 bool no_multiple_assignments()
const
179 auto result = (_assignments <= 1);
184 bool exactly_one_assignment()
const
186 auto result = (_assignments == 1);
196 mutable int _assignments = 0;
Hold current and old value of any type.
T & operator=(Arg &&arg)
Assignment operator.
const T & old() const
Get old value.
BlockParameter(Args &&... args)
Constructor. Any arguments are forwarded to both old and current value.
const T & get() const
Get current value.
bool changed() const
Check if value has changed between before the last assignment and now.
Curiously Recurring Template Pattern (CRTP) base class.
~CRTP()=default
Protected destructor to avoid base class pointers.
Classes derived from this class cannot be copied (but still moved).
~NonCopyable()=default
Protected non-virtual destructor.
NonCopyable()=default
Protected default constructor.
Audio Processing Framework.