Replace

Files CCore/inc/gadget/Replace.h CCore/src/gadget/Replace.cpp

Replace...() is a family of functions, they set the first argument to a new value and return the old value.

The basic of them is the simple Replace().


template <class T,class S>
T Replace(T &t,S a); // return <- t <- T(a)

There is also a set of variants:


template <class T>
T Replace_null(T &t); // return <- t <- T()

template <class T>
T Replace_min(T &t,T a); // return <- t <- Min<T>(t,a)
 
template <class T>
T Replace_max(T &t,T a); // return <- t <- Max<T>(t,a)
 
template <class T,class S>
T Replace_add(T &t,S a); // return <- t <- t+a
 
template <class T,class S>
T Replace_sub(T &t,S a); // return <- t <- t-a

The final one is generic, you can use it with lambdas:


template <class Func,class T>
T Replace_gen(Func func,T &t); // return <- t <- func(t)