proconlib

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

View the Project on GitHub KodamaD/proconlib

:heavy_check_mark: traits/optional_monoid.cpp

Required by

Verified with

Code

#pragma once
#include <optional>
#include <utility>

template <class S> struct OptionalMonoid {
    using Type = std::optional<typename S::Type>;
    static constexpr Type identity() { return std::nullopt; }
    static constexpr Type operation(const Type& l, const Type& r) {
        if (!l) return r;
        if (!r) return l;
        return Type(std::in_place, S::operation(*l, *r));
    }
};
#line 2 "traits/optional_monoid.cpp"
#include <optional>
#include <utility>

template <class S> struct OptionalMonoid {
    using Type = std::optional<typename S::Type>;
    static constexpr Type identity() { return std::nullopt; }
    static constexpr Type operation(const Type& l, const Type& r) {
        if (!l) return r;
        if (!r) return l;
        return Type(std::in_place, S::operation(*l, *r));
    }
};
Back to top page