Update template.cc
Signed-off-by: subcrip <contact@subc.rip>
This commit is contained in:
parent
f13045453e
commit
51616f316b
11
template.cc
11
template.cc
|
@ -1,8 +1,4 @@
|
||||||
#pragma GCC diagnostic ignored "-Wunused-const-variable"
|
// #pragma GCC target("popcnt,lzcnt,abm,bmi,bmi2")
|
||||||
#pragma GCC diagnostic ignored "-Wreorder"
|
|
||||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
|
||||||
#pragma GCC diagnostic ignored "-Wshift-op-parentheses"
|
|
||||||
#pragma GCC diagnostic ignored "-Wlogical-op-parentheses"
|
|
||||||
#pragma GCC optimize("Ofast")
|
#pragma GCC optimize("Ofast")
|
||||||
/************* This code requires C++17. ***************/
|
/************* This code requires C++17. ***************/
|
||||||
|
|
||||||
|
@ -399,9 +395,10 @@ bool chmin(T& lhs, const U& rhs) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define functor(func) [&](auto&&... val) \
|
#define functor(func) ([&](auto&&... val) \
|
||||||
noexcept(noexcept(func(std::forward<decltype(val)>(val)...))) -> decltype(auto) \
|
noexcept(noexcept(func(std::forward<decltype(val)>(val)...))) -> decltype(auto) \
|
||||||
{return func(std::forward<decltype(val)>(val)...);}
|
{return func(std::forward<decltype(val)>(val)...);})
|
||||||
|
#define expr(ret, ...) ([&] (__VA_ARGS__) { return (ret); })
|
||||||
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