1#ifndef UNIT_INTERVAL_HPP_BG1EK7QX
2#define UNIT_INTERVAL_HPP_BG1EK7QX
4#include <boost/operators.hpp>
12
13
14
15
16
17
18
19
27 constexpr explicit UnitInterval(
double v) : m_value(clamp(v)) {}
46 double value()
const {
return m_value; }
50 constexpr static double clamp(
double v)
52 return (v > 1.0 ? 1.0 : (v < 0.0 ? 0.0 : v));
60
61
62
63
64
68
69
70
71
72
75 typename std::enable_if<
76 std::is_convertible<
typename std::iterator_traits<Iterator>::value_type,
UnitInterval>::value,
84 for (Iterator it = begin; it != end; ++it)
90 return UnitInterval { count > 1 ? (accu / count) : accu };