competitive_library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub knshnb/competitive_library

:warning: src/Helper/MakeFixPoint.hpp

概要

ラムダ式による再帰のヘルパー

使い方

int main() {
    dfs = make_fix_point([&](auto&& self) -> T {
        return self();
    });
    dfs();
}

Code

/// @docs src/Helper/MakeFixPoint.md
template <typename F> struct FixPoint : F {
    FixPoint(F&& f) : F(std::forward<F>(f)) {}
    template <typename... Args> decltype(auto) operator()(Args&&... args) const {
        return F::operator()(*this, std::forward<Args>(args)...);
    }
};
template <typename F> decltype(auto) make_fix_point(F&& f) { return FixPoint<F>{std::forward<F>(f)}; }
#line 1 "src/Helper/MakeFixPoint.hpp"
/// @docs src/Helper/MakeFixPoint.md
template <typename F> struct FixPoint : F {
    FixPoint(F&& f) : F(std::forward<F>(f)) {}
    template <typename... Args> decltype(auto) operator()(Args&&... args) const {
        return F::operator()(*this, std::forward<Args>(args)...);
    }
};
template <typename F> decltype(auto) make_fix_point(F&& f) { return FixPoint<F>{std::forward<F>(f)}; }
Back to top page