Search code examples
c++qtmacrosclamp

rt_SATURATE Macro definition in Qt


Anyone knows below macro? I googled it but cant find anything useful. What does it do?

#define rt_SATURATE(sig,ll,ul) (((sig) >= (ul)) ? (ul) : (((sig) <= (ll)) ? (ll) : (sig)) )

Solution

  • It does what std::clamp does.

    It "returns" sig restricted to a range given by ll (lower limit) and ul (upper limit).

    As the question is tagged with another alternative doing the same thing but with different order to the parameters is qBound