General Purpose library for Freestanding C++ and POSIX systems
Nevar pievienot vairāk kā 25 tēmas
Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
|
#pragma once
|
|
|
|
#include "gp_config.hpp"
|
|
|
|
#include "gp/algorithms/move.hpp"
|
|
|
|
namespace gp{
|
|
|
|
template<typename T>
|
|
T identity(T v){return v;}
|
|
template<typename T>
|
|
T& identity(T& v){return v;}
|
|
|
|
template<typename it, typename transform>
|
|
auto&& min_of(it beg, it end, transform fn = identity) {
|
|
gp_config::assertion(beg != end, "min_of provided with empty range");
|
|
auto fn_v = fn(*beg);
|
|
++beg;
|
|
while(beg != end) {
|
|
auto n_fn_v = fn(*beg);
|
|
if(n_fn_v < fn_v) {
|
|
fn_v = n_fn_v;
|
|
}
|
|
++beg;
|
|
}
|
|
return gp::move(fn_v);
|
|
}
|
|
}
|