2
3
4
5
6
7
8
9
10
11
12
13
14
15
17#ifndef MIR_GEOMETRY_SIZE_H_
18#define MIR_GEOMETRY_SIZE_H_
40 constexpr Size()
noexcept {}
41 constexpr Size(
Size const&)
noexcept =
default;
45 explicit constexpr Size(
Size<U>
const& other)
noexcept
46 :
width{Width<T>{other.width}},
47 height{Height<T>{other.height}}
51 template<
typename WidthType,
typename HeightType>
52 constexpr Size(WidthType&& width, HeightType&& height)
noexcept :
width(width),
height(height) {}
61 return lhs.width == rhs.width && lhs.height == rhs.height;
67 return lhs.width != rhs.width || lhs.height != rhs.height;
71std::ostream& operator<<(std::ostream& out,
Size<T>
const& value)
73 out <<
'(' << value.width <<
", " << value.height <<
')';
77template<
typename T,
typename Scalar>
80 return Size<T>{scale*size.width, scale*size.height};
83template<
typename T,
typename Scalar>
89template<
typename T,
typename Scalar>
92 return Size<T>{size.width / scale, size.height / scale};
98 return Size<T>{point.x.as_value(), point.y.as_value()};
104 return Point<T>{size.width.as_value(), size.height.as_value()};
constexpr Size< T > as_size(Point< T > const &point)
Definition: size.h:96
constexpr Point< T > as_point(Size< T > const &size)
Definition: size.h:102
constexpr Size< T > operator*(Size< T > const &size, Scalar scale)
Definition: size.h:84
constexpr Size< T > operator*(Scalar scale, Size< T > const &size)
Definition: size.h:78
constexpr Size< T > operator/(Size< T > const &size, Scalar scale)
Definition: size.h:90
constexpr bool operator!=(Size< T > const &lhs, Size< T > const &rhs)
Definition: size.h:65
constexpr bool operator==(Size< T > const &lhs, Size< T > const &rhs)
Definition: size.h:59
Basic geometry types. Types for dimensions, displacements, etc. and the operations that they support.
Definition: size.h:27
Size & operator=(Size const &) noexcept=default
constexpr Size() noexcept
Definition: size.h:40
constexpr Size(Size< U > const &other) noexcept
Definition: size.h:45
constexpr Size(WidthType &&width, HeightType &&height) noexcept
Definition: size.h:52
Height< T > height
Definition: size.h:55
constexpr Size(Size const &) noexcept=default
Width< T > width
Definition: size.h:54