template<DimensionTag Tag, typename IntegerType>
class core::ubuntu::media::video::detail::IntWrapper< Tag, IntegerType >
IntWrapper is a type-safe integer that allows for encoding/enforcing semantics by means of tags.
- Template Parameters
-
Tag | Hint for the compiler on the semantics of the underlying integer. |
IntegerType | The underlying integer type. |
Handling dimensions like width and height with raw integer values is tedious and error prone as the compiler has no way of distinguishing a width from a height, or an x coordinate from a y coordinate. The problem is solvable with the tagged integer type presented here. Consider the following example:
typedef IntWrapper<DimensionTag::width, std::uint32_t>
Width;
typedef IntWrapper<DimensionTag::height, std::uint32_t>
Height;
void an_unsafe_function_expecting_width_and_height(std::uint32_t
width, std::uint32_t
height);
{
std::uint unsafe_width{640}, unsafe_height{480};
an_unsafe_function_expecting_width_and_height(unsafe_height, unsafe_width);
a_safe_function_expecting_width_and_height(
height,
width);
}
Definition at line 68 of file dimensions.h.