ecnerwala's competitive programming library
#include "reverse_comparator.hpp"
| Coverage | Exec / Excl / Total | |
|---|---|---|
| Lines | 20.0% | 2 / 0 / 10 |
| Full report |
#pragma once
#include <functional>
#include <utility>
template <typename F> struct reverse_comparator_t {
F f;
template <typename Arg1, typename Arg2> constexpr bool operator() (Arg1&& arg1, Arg2&& arg2) & {
return f(std::forward<Arg2>(arg2), std::forward<Arg1>(arg1));
}
template <typename Arg1, typename Arg2> constexpr bool operator() (Arg1&& arg1, Arg2&& arg2) const& {
return f(std::forward<Arg2>(arg2), std::forward<Arg1>(arg1));
}
template <typename Arg1, typename Arg2> constexpr bool operator() (Arg1&& arg1, Arg2&& arg2) && {
return std::move(f)(std::forward<Arg2>(arg2), std::forward<Arg1>(arg1));
}
template <typename Arg1, typename Arg2> constexpr bool operator() (Arg1&& arg1, Arg2&& arg2) const&& {
return std::move(f)(std::forward<Arg2>(arg2), std::forward<Arg1>(arg1));
}
};
template <typename F> constexpr reverse_comparator_t<std::decay_t<F>> reverse_comparator(F&& f) {
return { std::forward<F>(f) };
}
#include <functional>
#include <utility>
#line 2 "src/reverse_comparator.hpp"
#line 5 "src/reverse_comparator.hpp"
template <typename F> struct reverse_comparator_t {
F f;
template <typename Arg1, typename Arg2> constexpr bool operator() (Arg1&& arg1, Arg2&& arg2) & {
return f(std::forward<Arg2>(arg2), std::forward<Arg1>(arg1));
}
template <typename Arg1, typename Arg2> constexpr bool operator() (Arg1&& arg1, Arg2&& arg2) const& {
return f(std::forward<Arg2>(arg2), std::forward<Arg1>(arg1));
}
template <typename Arg1, typename Arg2> constexpr bool operator() (Arg1&& arg1, Arg2&& arg2) && {
return std::move(f)(std::forward<Arg2>(arg2), std::forward<Arg1>(arg1));
}
template <typename Arg1, typename Arg2> constexpr bool operator() (Arg1&& arg1, Arg2&& arg2) const&& {
return std::move(f)(std::forward<Arg2>(arg2), std::forward<Arg1>(arg1));
}
};
template <typename F> constexpr reverse_comparator_t<std::decay_t<F>> reverse_comparator(F&& f) {
return { std::forward<F>(f) };
}
// clang-format off
// @formatter:off
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wmisleading-indentation"
#pragma GCC diagnostic ignored "-Wmultistatement-macros"
#include <bits/stdc++.h>
// src/reverse_comparator.hpp
template<typename F>struct reverse_comparator_t{
F f;
template<typename Arg1,typename Arg2>constexpr bool operator()(Arg1&&arg1,Arg2&&arg2)&{
return f(std::forward<Arg2>(arg2),std::forward<Arg1>(arg1));
}
template<typename Arg1,typename Arg2>constexpr bool operator()(Arg1&&arg1,Arg2&&arg2)const&{
return f(std::forward<Arg2>(arg2),std::forward<Arg1>(arg1));
}
template<typename Arg1,typename Arg2>constexpr bool operator()(Arg1&&arg1,Arg2&&arg2)&&{
return std::move(f)(std::forward<Arg2>(arg2),std::forward<Arg1>(arg1));
}
template<typename Arg1,typename Arg2>constexpr bool operator()(Arg1&&arg1,Arg2&&arg2)const&&{
return std::move(f)(std::forward<Arg2>(arg2),std::forward<Arg1>(arg1));
}
};
template<typename F>constexpr reverse_comparator_t<std::decay_t<F>>reverse_comparator(F&&f){
return{std::forward<F>(f)};
}
#pragma GCC diagnostic pop
// clang-format on
// @formatter:on
#pragma once
#include <functional>
#include <utility>
template <typename F> struct reverse_comparator_t {
F f;
template <typename Arg1, typename Arg2> constexpr bool operator() (Arg1&& arg1, Arg2&& arg2) & {
return f(std::forward<Arg2>(arg2), std::forward<Arg1>(arg1));
}
template <typename Arg1, typename Arg2> constexpr bool operator() (Arg1&& arg1, Arg2&& arg2) const& {
return f(std::forward<Arg2>(arg2), std::forward<Arg1>(arg1));
}
template <typename Arg1, typename Arg2> constexpr bool operator() (Arg1&& arg1, Arg2&& arg2) && {
return std::move(f)(std::forward<Arg2>(arg2), std::forward<Arg1>(arg1));
}
template <typename Arg1, typename Arg2> constexpr bool operator() (Arg1&& arg1, Arg2&& arg2) const&& {
return std::move(f)(std::forward<Arg2>(arg2), std::forward<Arg1>(arg1));
}
};
template <typename F> constexpr reverse_comparator_t<std::decay_t<F>> reverse_comparator(F&& f) {
return { std::forward<F>(f) };
}