1
0
Fork 0

Update template.cc

Signed-off-by: subcrip <contact@subc.rip>
This commit is contained in:
subcrip 2024-08-05 22:58:39 +08:00
parent f13045453e
commit 51616f316b
1 changed files with 4 additions and 7 deletions

View File

@ -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)); });
} }