1#ifndef UNIT_INTERVAL_HPP_BG1EK7QX
2#define UNIT_INTERVAL_HPP_BG1EK7QX
4#include <boost/operators.hpp>
21 boost::arithmetic<UnitInterval>,
22 boost::arithmetic<UnitInterval, double>,
23 boost::totally_ordered<UnitInterval>
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));
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 };