@@ -5,26 +5,46 @@ namespace av {
5
5
class Rect
6
6
{
7
7
public:
8
- Rect ();
9
- Rect (int width, int height);
10
- Rect (int x, int y, int width, int height);
8
+ Rect () noexcept = default ;
9
+ Rect (int width, int height) noexcept ;
10
+ Rect (int x, int y, int width, int height) noexcept ;
11
11
12
- void setX (int x) { this ->x = x; }
13
- void setY (int y) { this ->y = y; }
14
- void setWidth (int w) { width = w; }
15
- void setHeight (int h) { height = h; }
12
+ void setX (int x) noexcept { this ->x = x; }
13
+ void setY (int y) noexcept { this ->y = y; }
14
+ void setWidth (int w) noexcept { width = w; }
15
+ void setHeight (int h) noexcept { height = h; }
16
16
17
- int getX () { return x; }
18
- int getY () { return y; }
19
- int getWidth () { return width; }
20
- int getHeight () { return height; }
17
+ int getX () const noexcept { return x; }
18
+ int getY () const noexcept { return y; }
19
+ int getWidth () const noexcept { return width; }
20
+ int getHeight () const noexcept { return height; }
21
21
22
22
private:
23
- int x;
24
- int y;
25
- int width;
26
- int height;
23
+ int x{} ;
24
+ int y{} ;
25
+ int width{} ;
26
+ int height{} ;
27
27
};
28
28
29
29
} // ::av
30
30
31
+ #if __has_include(<format>)
32
+ #include < format>
33
+ #ifdef __cpp_lib_format
34
+ // std::format
35
+ template <typename CharT>
36
+ struct std ::formatter<av::Rect, CharT>
37
+ {
38
+ template <typename ParseContext>
39
+ constexpr auto parse (ParseContext& ctx)
40
+ {
41
+ return ctx.begin ();
42
+ }
43
+ template <typename ParseContext>
44
+ auto format (const av::Rect& value, ParseContext& ctx) const
45
+ {
46
+ return std::format_to (ctx.out (), " {}x{}{:+}{:+}" , value.getWidth (), value.getHeight (), value.getX (), value.getY ());
47
+ }
48
+ };
49
+ #endif // __cpp_lib_format
50
+ #endif // __has_include
0 commit comments