21 lines
302 B
C
21 lines
302 B
C
|
/*
|
||
|
* Clamp.h
|
||
|
*
|
||
|
* Created on: May 7, 2013
|
||
|
* Author: chibi_000
|
||
|
*/
|
||
|
|
||
|
#ifndef CLAMP_H_
|
||
|
#define CLAMP_H_
|
||
|
|
||
|
#include <algorithm>
|
||
|
|
||
|
template <typename A, typename B, typename C>
|
||
|
A clamp (A value, B minimum, C maximum)
|
||
|
{
|
||
|
return std::min( std::max(value, minimum) , maximum);
|
||
|
}
|
||
|
|
||
|
|
||
|
#endif /* CLAMP_H_ */
|