1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once


#include <utility>
#include <limits><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <functional><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include "internal/dev_env.hpp"
#include "algebraic/base.hpp"


namespace uni {

namespace algebraic {


template<class T>
struct minmax : base<std::pair<T, T>>, scalar_multipliable<minmax<T>>::identity, associative, commutative {
    using base<std::pair<T, T>>::base;

    minmax() noexcept(NO_EXCEPT)
      : minmax(std::numeric_limits<T>::max(), std::numeric_limits<T>::lowest())
    {};

    minmax(const T& v) noexcept(NO_EXCEPT) : minmax(v, v) {};


    friend inline minmax operator+(const minmax& lhs, const minmax& rhs) noexcept(NO_EXCEPT) {
        return minmax({ std::min(lhs.val().first, rhs->first), std::max(lhs.val().second, rhs->second) });
    }
};


} // namespace algebraic

} // namespace uni