20template<
typename Traits>
26 static_assert(std::is_integral_v<QuantizedType>,
27 "Quantized: QuantizedType must be integral");
28 static_assert(std::is_floating_point_v<FloatingType>,
29 "Quantized: FloatingType must be floating");
40 : quantized_(x), value_(Traits::toFloat(x))
56 constexpr float value()
const {
return value_; }
61 return quantized_ == other.quantized_;
66 return !(*
this == other);
73 <<
":" << q.
value() <<
"]";
Top-level libcamera namespace.
Definition backtrace.h:17
Wrapper that stores a value in both quantized and floating-point form.
Definition quantized.h:21
friend std::ostream & operator<<(std::ostream &out, const Quantized< Traits > &q)
Insert a text representation of a Quantized into an output stream.
Definition quantized.h:69
constexpr float value() const
Retrieve the floating-point representation.
Definition quantized.h:56
typename Traits::FloatingType FloatingType
The floating type used for the value representation.
Definition quantized.h:24
constexpr QuantizedType quantized() const
Retrieve the quantized integer representation.
Definition quantized.h:57
Traits TraitsType
The traits policy type defining the quantization behaviour.
Definition quantized.h:22
constexpr bool operator==(const Quantized &other) const
Compare two Quantized objects for equality.
Definition quantized.h:59
constexpr Quantized(QuantizedType x)
Construct a Quantized value from an existing quantized integer.
Definition quantized.h:39
typename Traits::QuantizedType QuantizedType
The integer type used for the quantized representation.
Definition quantized.h:23
constexpr Quantized(FloatingType x)
Construct a Quantized value from a floating-point number.
Definition quantized.h:34
constexpr Quantized & operator=(QuantizedType x)
Assign a quantized integer value to the Quantized object.
Definition quantized.h:50
constexpr bool operator!=(const Quantized &other) const
Compare two Quantized objects for inequality.
Definition quantized.h:64
constexpr Quantized & operator=(float x)
Assign a floating-point value to the Quantized object.
Definition quantized.h:44
Miscellaneous utility functions.