mirror of
https://github.com/ksherlock/TwoTerm.git
synced 2024-12-21 16:30:24 +00:00
c++17 algorithm.
git-svn-id: svn://qnap.local/TwoTerm/trunk@3138 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
parent
2bff238150
commit
4da42afc94
28
cpp/algorithm.h
Normal file
28
cpp/algorithm.h
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// algorithm_17.h
|
||||
// 2Term
|
||||
//
|
||||
// Created by Kelvin Sherlock on 7/12/2016.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef algorithm_17_h
|
||||
#define algorithm_17_h
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
// c++17
|
||||
|
||||
template<class T, class Compare>
|
||||
constexpr const T& clamp( const T& v, const T& lo, const T& hi, Compare comp ) {
|
||||
return comp(v, hi) ? std::max(v, lo, comp) : std::min(v, hi, comp);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
constexpr const T& clamp( const T& v, const T& lo, const T& hi ) {
|
||||
return clamp( v, lo, hi, std::less<T>() );
|
||||
}
|
||||
|
||||
|
||||
#endif /* algorithm_17_h */
|
Loading…
Reference in New Issue
Block a user