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()};
std::ostream & operator<<(std::ostream &out, W const &value)
Definition: dimensions_generic.h:144
constexpr S operator/(S const &size, Scalar scale)
Definition: size_generic.h:100
constexpr D::PointType as_point(D const &disp)
Definition: displacement_generic.h:180
constexpr bool operator!=(D const &lhs, D const &rhs)
Definition: displacement_generic.h:77
constexpr D::SizeType as_size(D const &disp)
Definition: displacement_generic.h:168
constexpr D operator*(Scalar scale, D const &disp)
Definition: displacement_generic.h:150
constexpr bool operator==(D const &lhs, D const &rhs)
Definition: displacement_generic.h:71
Definition: splash_session.h:24
Definition: displacement.h:32
Used for determining if a type is a size.
Definition: size_generic.h:32
Definition: displacement_generic.h:45
Definition: point_generic.h:42
Definition: size_generic.h:43
Size & operator=(Size const &) noexcept=default
T< Tag > Corresponding
Definition: size_generic.h:45
T< WidthTag > width
Definition: size_generic.h:64
constexpr Size() noexcept
Definition: size_generic.h:50
constexpr Size(S const &other) noexcept
Definition: size_generic.h:55
constexpr Size(WidthType &&width, HeightType &&height) noexcept
Definition: size_generic.h:62
T< HeightTag > height
Definition: size_generic.h:65
constexpr Size(Size const &) noexcept=default