feat add clamp
All checks were successful
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 1m0s
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m7s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m12s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 1m12s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Successful in 1m13s
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (pull_request) Successful in 1m2s
linux-mips64-gcc / linux-gcc-mips64el (push) Successful in 1m38s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (pull_request) Successful in 59s
linux-x64-gcc / linux-gcc (push) Successful in 1m53s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (pull_request) Successful in 1m2s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (pull_request) Successful in 1m13s
linux-hisiv500-gcc / linux-gcc-hisiv500 (pull_request) Successful in 1m24s
linux-mips64-gcc / linux-gcc-mips64el (pull_request) Successful in 1m28s
linux-x64-gcc / linux-gcc (pull_request) Successful in 1m52s
All checks were successful
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 1m0s
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m7s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m12s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 1m12s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Successful in 1m13s
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (pull_request) Successful in 1m2s
linux-mips64-gcc / linux-gcc-mips64el (push) Successful in 1m38s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (pull_request) Successful in 59s
linux-x64-gcc / linux-gcc (push) Successful in 1m53s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (pull_request) Successful in 1m2s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (pull_request) Successful in 1m13s
linux-hisiv500-gcc / linux-gcc-hisiv500 (pull_request) Successful in 1m24s
linux-mips64-gcc / linux-gcc-mips64el (pull_request) Successful in 1m28s
linux-x64-gcc / linux-gcc (pull_request) Successful in 1m52s
This commit is contained in:
parent
1610953cd8
commit
af72a33e68
22
src/ulib/utils/utils.h
Normal file
22
src/ulib/utils/utils.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef ULIB_SRC_ULIB_UTILS_UTILS_H_
|
||||
#define ULIB_SRC_ULIB_UTILS_UTILS_H_
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace ulib {
|
||||
template<typename T>
|
||||
const T &
|
||||
Clamp(const T &value, const T &low, const T &high)
|
||||
{
|
||||
return Clamp(value, low, high, std::less<T>{});
|
||||
}
|
||||
|
||||
template<typename T, typename Comp>
|
||||
const T &
|
||||
Clamp(const T &value, const T &low, const T &high, Comp comp)
|
||||
{
|
||||
return comp(value, low) ? low : (comp(high, value) ? high : value);
|
||||
}
|
||||
|
||||
}// namespace ulib
|
||||
#endif// ULIB_SRC_ULIB_UTILS_UTILS_H_
|
Loading…
x
Reference in New Issue
Block a user