19 #ifndef MIR_GEOMETRY_SIZE_GENERIC_H_
20 #define MIR_GEOMETRY_SIZE_GENERIC_H_
36 template<
template<
typename>
typename T>
38 template<
template<
typename>
typename T>
41 template<
template<
typename>
typename T>
44 template<
typename Tag>
50 constexpr
Size() noexcept {}
51 constexpr
Size(
Size const&) noexcept =
default;
54 template<typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
55 explicit constexpr
Size(S
const& other) noexcept
56 :
width{T<WidthTag>{other.width}},
57 height{T<HeightTag>{other.height}}
61 template<
typename W
idthType,
typename HeightType>
68 template<typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
69 inline constexpr
bool operator == (S
const& lhs, S
const& rhs)
71 return lhs.width == rhs.width && lhs.height == rhs.height;
74 template<typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
75 inline constexpr
bool operator != (S
const& lhs, S
const& rhs)
77 return lhs.width != rhs.width || lhs.height != rhs.height;
80 template<typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
81 std::ostream&
operator<<(std::ostream& out, S
const& value)
83 out <<
'(' << value.width <<
", " << value.height <<
')';
87 template<typename Scalar, typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
88 inline constexpr S
operator*(Scalar scale, S
const& size)
90 return S{scale*size.width, scale*size.height};
93 template<typename Scalar, typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
94 inline constexpr S
operator*(S
const& size, Scalar scale)
99 template<typename Scalar, typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
100 inline constexpr S
operator/(S
const& size, Scalar scale)
102 return S{size.width / scale, size.height / scale};
105 template<typename P, typename std::enable_if<std::is_base_of<detail::PointBase, P>::value,
bool>::type =
true>
106 inline constexpr
typename P::SizeType
as_size(P
const& point)
108 return typename P::SizeType{point.x.as_value(), point.y.as_value()};
111 template<typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
112 inline constexpr
typename S::PointType
as_point(S
const& size)
114 return typename S::PointType{size.width.as_value(), size.height.as_value()};
120 #endif // MIR_GEOMETRY_SIZE_GENERIC_H_