34 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT) 35 #error "Only <final/final.h> can be included directly." 41 #include "final/util/fstring.h" 54 using coordinate_type = int;
55 using coordinate_reference = coordinate_type&;
58 constexpr
FPoint () noexcept =
default;
59 constexpr
FPoint (coordinate_type, coordinate_type) noexcept;
68 ~
FPoint() noexcept =
default;
71 constexpr
auto operator = (
const FPoint&) noexcept ->
FPoint& =
default;
74 constexpr
auto operator = (
FPoint&&) noexcept ->
FPoint& =
default;
81 auto getClassName()
const ->
FString;
82 constexpr
auto getX()
const noexcept -> coordinate_type;
83 constexpr
auto getY()
const noexcept -> coordinate_type;
86 constexpr
void setX (coordinate_type) noexcept;
87 constexpr
void setY (coordinate_type) noexcept;
88 constexpr
void setPoint (
const FPoint&) noexcept;
89 constexpr
void setPoint (coordinate_type, coordinate_type) noexcept;
92 constexpr
auto isOrigin()
const noexcept -> bool;
95 constexpr
auto x_ref() & noexcept -> coordinate_type&;
96 constexpr
auto y_ref() & noexcept -> coordinate_type&;
99 constexpr
void move (coordinate_type, coordinate_type) noexcept;
100 constexpr
void move (
const FPoint&) noexcept;
101 constexpr
void swap (
FPoint&) noexcept;
105 coordinate_type xpos{0};
106 coordinate_type ypos{0};
109 friend constexpr
auto operator == (
const FPoint& p1,
const FPoint& p2) ->
bool 111 return p1.xpos == p2.xpos && p1.ypos == p2.ypos;
114 friend constexpr
auto operator != (
const FPoint& p1,
const FPoint& p2) ->
bool 116 return ! ( p1 == p2 );
121 return {p1.xpos + p2.xpos, p1.ypos + p2.ypos};
126 return {p1.xpos - p2.xpos, p1.ypos - p2.ypos};
129 friend constexpr
auto operator - (
const FPoint& p) ->
FPoint 131 return {-p.xpos, -p.ypos};
134 friend inline auto operator << (std::ostream& outstr,
const FPoint& p) -> std::ostream&
136 outstr << p.xpos <<
" " << p.ypos;
140 friend inline auto operator >> (std::istream& instr,
FPoint& p) -> std::istream&
145 if ( instr >> x >> y )
155 constexpr FPoint::FPoint (coordinate_type x, coordinate_type y) noexcept
161 inline auto FPoint::getClassName()
const ->
FString 165 constexpr
auto FPoint::getX()
const noexcept -> coordinate_type
169 constexpr
auto FPoint::getY()
const noexcept -> coordinate_type
173 constexpr
void FPoint::setX (coordinate_type x) noexcept
177 constexpr
void FPoint::setY (coordinate_type y) noexcept
181 constexpr
void FPoint::setPoint (
const FPoint& p) noexcept
182 { setPoint(p.xpos, p.ypos); }
185 constexpr
void FPoint::setPoint (coordinate_type x, coordinate_type y) noexcept
192 constexpr
auto FPoint::isOrigin()
const noexcept ->
bool 193 {
return xpos == 0 && ypos == 0; }
196 constexpr
auto FPoint::x_ref() & noexcept -> coordinate_reference
200 constexpr
auto FPoint::y_ref() & noexcept -> coordinate_reference
204 constexpr
void FPoint::move (coordinate_type dx, coordinate_type dy) noexcept
211 constexpr
void FPoint::move (
const FPoint& d) noexcept
218 constexpr
void FPoint::swap (
FPoint& p) noexcept
220 coordinate_type tmp_x{xpos};
221 coordinate_type tmp_y{ypos};
Definition: class_template.cpp:25