Update include.hh
Signed-off-by: subcrip <contact@subc.rip>
This commit is contained in:
parent
362e781459
commit
4b5dd8da79
|
@ -429,6 +429,9 @@ istream& operator>>(istream& in, MLLd& num) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// miscancellous
|
// miscancellous
|
||||||
|
#define functor(func) [&](auto&&... val) \
|
||||||
|
noexcept(noexcept(func(std::forward<decltype(val)>(val)...))) -> decltype(auto) \
|
||||||
|
{return func(std::forward<decltype(val)>(val)...);}
|
||||||
template <typename Func, typename RandomIt> void sort_by_key(RandomIt first, RandomIt last, Func extractor) {
|
template <typename Func, typename RandomIt> void sort_by_key(RandomIt first, RandomIt last, Func extractor) {
|
||||||
std::sort(first, last, [&] (auto&& a, auto&& b) { return std::less<>()(extractor(a), extractor(b)); });
|
std::sort(first, last, [&] (auto&& a, auto&& b) { return std::less<>()(extractor(a), extractor(b)); });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue