cp-documentation

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

View the Project on GitHub zawa-tin/cp-documentation

:warning: Src/Algebra/Monoid/SemigroupMonoid.hpp

Code

#pragma once

#include <optional>

namespace zawa {

template <class Semigroup>
struct SemigroupMonoid {
    using Element = std::optional<typename Semigroup::Element>;
    static Element identity() noexcept {
        return std::nullopt;
    }
    static Element operation(const Element& a, const Element& b) noexcept {
        if (!a) return b;
        else if (!b) return a;
        else return Semigroup::operation(a.value(), b.value());
    }
};

} // namespace zawa
#line 2 "Src/Algebra/Monoid/SemigroupMonoid.hpp"

#include <optional>

namespace zawa {

template <class Semigroup>
struct SemigroupMonoid {
    using Element = std::optional<typename Semigroup::Element>;
    static Element identity() noexcept {
        return std::nullopt;
    }
    static Element operation(const Element& a, const Element& b) noexcept {
        if (!a) return b;
        else if (!b) return a;
        else return Semigroup::operation(a.value(), b.value());
    }
};

} // namespace zawa
Back to top page