Skip to content

Commit eb7ae3d

Browse files
committed
refactoring
1 parent 64aa176 commit eb7ae3d

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/ruis/util/sides.hpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,28 +139,30 @@ class sides : public std::array<component_type, 4>
139139
}
140140

141141
/**
142-
* @brief Comparator functor.
142+
* @brief Operator less than.
143143
* Implements operation < for sides.
144144
* For use with std::map, etc.
145+
* @param lhs - left hand side operand.
146+
* @param rhs - right hand side operand.
147+
* @return true if lhs < rhs.
148+
* @return false otherwise.
145149
*/
146-
struct comparator {
147-
bool operator()(
148-
const sides& lhs, //
149-
const sides& rhs
150-
) const
151-
{
152-
if (lhs.left() == rhs.left()) {
153-
if (lhs.top() == rhs.top()) {
154-
if (lhs.right() == rhs.right()) {
155-
return lhs.bottom() < rhs.bottom();
156-
}
157-
return lhs.right() < rhs.right();
150+
friend bool operator<(
151+
const sides& lhs, //
152+
const sides& rhs
153+
)
154+
{
155+
if (lhs.left() == rhs.left()) {
156+
if (lhs.top() == rhs.top()) {
157+
if (lhs.right() == rhs.right()) {
158+
return lhs.bottom() < rhs.bottom();
158159
}
159-
return lhs.top() < rhs.top();
160+
return lhs.right() < rhs.right();
160161
}
161-
return lhs.left() < rhs.left();
162+
return lhs.top() < rhs.top();
162163
}
163-
};
164+
return lhs.left() < rhs.left();
165+
}
164166
};
165167

166168
} // namespace ruis

src/ruis/widget/label/rectangle.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ using namespace ruis;
3030

3131
std::map<
3232
sides<real>, //
33-
std::weak_ptr<rectangle::rounded_corners_texture>,
34-
sides<real>::comparator //
33+
std::weak_ptr<rectangle::rounded_corners_texture>
3534
>
3635
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables, "false-positive")
3736
rectangle::cache;

src/ruis/widget/label/rectangle.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ class rectangle :
9999

100100
static std::map<
101101
sides<real>, //
102-
std::weak_ptr<rounded_corners_texture>,
103-
sides<real>::comparator //
102+
std::weak_ptr<rounded_corners_texture>
104103
>
105104
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables, "false-positive")
106105
cache;

0 commit comments

Comments
 (0)