Template Struct Value¶
Defined in File dimensions.h
Struct Documentation¶
-
template<typename T, typename Tag>
struct Value¶ Wraps a geometry value and prevents it from being accidentally used for invalid operations (such as setting a width to a height or adding two x positions together). Of course, explicit casts are possible to get around these restrictions (see the as_*() functions).
Public Functions
-
template<typename Q = T>
inline constexpr std::enable_if<std::is_integral<Q>::value, int>::type as_int() const¶
-
template<typename Q = T>
inline constexpr std::enable_if<std::is_integral<Q>::value, uint32_t>::type as_uint32_t() const¶
-
template<typename Q>
inline constexpr Q as() const¶ Losslessly extract the underlying value.
The as<Q> accessor will exist for any numeric type Q that can exactly represent any valid ValueType
For example, if ValueType is int32_t, then as<int64_t> and as<double> both exist as an i32 is exactly representable in a double, but as<uint64_t> and as<float> do not exist, as int32_t can contain negative values not representable in uint64_t, and float does not have sufficient precision to exactly represent any int32_t value.
-
template<typename Q>
inline constexpr Q round_to() const¶ Convert to a different type, possibly losing precision but not range.
The round_to<Q> accessor will exist for any numeric type Q that have enough range to represent any valid ValueType.
-
inline constexpr Value() noexcept¶
-
template<typename Q = T>