17 #ifndef MIR_GEOMETRY_SIZE_GENERIC_H_
18 #define MIR_GEOMETRY_SIZE_GENERIC_H_
34 template<
template<
typename>
typename T>
36 template<
template<
typename>
typename T>
39 template<
template<
typename>
typename T>
42 template<
typename Tag>
48 constexpr
Size() noexcept {}
49 constexpr
Size(
Size const&) noexcept =
default;
52 template<typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
53 explicit constexpr
Size(S
const& other) noexcept
54 :
width{T<WidthTag>{other.width}},
55 height{T<HeightTag>{other.height}}
59 template<
typename W
idthType,
typename HeightType>
66 template<typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
67 inline constexpr
bool operator == (S
const& lhs, S
const& rhs)
69 return lhs.width == rhs.width && lhs.height == rhs.height;
72 template<typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
73 inline constexpr
bool operator != (S
const& lhs, S
const& rhs)
75 return lhs.width != rhs.width || lhs.height != rhs.height;
78 template<typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
79 std::ostream&
operator<<(std::ostream& out, S
const& value)
81 out <<
'(' << value.width <<
", " << value.height <<
')';
85 template<typename Scalar, typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
86 inline constexpr S
operator*(Scalar scale, S
const& size)
88 return S{scale*size.width, scale*size.height};
91 template<typename Scalar, typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
92 inline constexpr S
operator*(S
const& size, Scalar scale)
97 template<typename Scalar, typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
98 inline constexpr S
operator/(S
const& size, Scalar scale)
100 return S{size.width / scale, size.height / scale};
103 template<typename P, typename std::enable_if<std::is_base_of<detail::PointBase, P>::value,
bool>::type =
true>
104 inline constexpr
typename P::SizeType
as_size(P
const& point)
106 return typename P::SizeType{point.x.as_value(), point.y.as_value()};
109 template<typename S, typename std::enable_if<std::is_base_of<detail::SizeBase, S>::value,
bool>::type =
true>
110 inline constexpr
typename S::PointType
as_point(S
const& size)
112 return typename S::PointType{size.width.as_value(), size.height.as_value()};
std::ostream & operator<<(std::ostream &out, W const &value)
Definition: dimensions_generic.h:142
constexpr S operator/(S const &size, Scalar scale)
Definition: size_generic.h:98
constexpr D::PointType as_point(D const &disp)
Definition: displacement_generic.h:178
constexpr bool operator!=(D const &lhs, D const &rhs)
Definition: displacement_generic.h:75
constexpr D::SizeType as_size(D const &disp)
Definition: displacement_generic.h:166
constexpr D operator*(Scalar scale, D const &disp)
Definition: displacement_generic.h:148
constexpr bool operator==(D const &lhs, D const &rhs)
Definition: displacement_generic.h:69
Definition: splash_session.h:22
Definition: displacement.h:30
Used for determining if a type is a size.
Definition: size_generic.h:30
Definition: displacement_generic.h:43
Definition: point_generic.h:40
Definition: size_generic.h:41
Size & operator=(Size const &) noexcept=default
T< Tag > Corresponding
Definition: size_generic.h:43
T< WidthTag > width
Definition: size_generic.h:62
constexpr Size() noexcept
Definition: size_generic.h:48
constexpr Size(S const &other) noexcept
Definition: size_generic.h:53
constexpr Size(WidthType &&width, HeightType &&height) noexcept
Definition: size_generic.h:60
T< HeightTag > height
Definition: size_generic.h:63
constexpr Size(Size const &) noexcept=default