opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
normalized.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <compare>
6#include <concepts>
7#include <ostream>
8
9namespace osc
10{
11 // validated wrapper for "a floating point value that lies within the closed interval [0.0, 1.0]"
12 template<std::floating_point T>
14 public:
15 constexpr Normalized() = default;
16 constexpr Normalized(T value) : value_{saturate(value)} {}
17
18 friend bool operator==(const Normalized&, const Normalized&) = default;
19 friend auto operator<=>(const Normalized&, const Normalized&) = default;
20
21 constexpr const T& get() const { return value_; }
22 constexpr operator const T& () const { return value_; }
23 private:
24 T value_{};
25 };
26
27 template<std::floating_point T>
28 std::ostream& operator<<(std::ostream& out, const Normalized<T>& normalized_value)
29 {
30 return out << normalized_value.get();
31 }
32}
Definition normalized.h:13
constexpr Normalized(T value)
Definition normalized.h:16
friend auto operator<=>(const Normalized &, const Normalized &)=default
friend bool operator==(const Normalized &, const Normalized &)=default
constexpr Normalized()=default
constexpr const T & get() const
Definition normalized.h:21
Definition custom_decoration_generator.h:5
std::ostream & operator<<(std::ostream &, const Object &)
constexpr Rgba< T > saturate(const Rgba< T > &x)
Definition rgba.h:237
constexpr U to(T &&value)
Definition conversion.h:56