NyaanNyaan / library

Competitive Programming Library
https://nyaannyaan.github.io/library/
Creative Commons Zero v1.0 Universal
215 stars 17 forks source link

Minor fixes #101

Closed ghost closed 9 months ago

ghost commented 9 months ago

Fixes are really minor but I think you should look at them. For example, with the Li-Chao tree impl, you might benefit from holding large constant values with std::numeric_limits, namely

static const T INF = std::numeric_limits<T>::max();

Also, as far as I understood your code, inner_update is only meant for internal use, wouldnt it be better to make it private within the class (?)

This file might also be a good addition, but is really up to you

#pragma once

#include <functional>
#include <utility>

namespace std {

template<class Fun>
class y_combinator_result {
    Fun fun_;
public:
    template<class T>
    explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}

    template<class ...Args>
    decltype(auto) operator()(Args &&...args) {
        return fun_(std::ref(*this), std::forward<Args>(args)...);
    }
};

template<class Fun>
decltype(auto) y_combinator(Fun &&fun) {
    return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

} // namespace std