Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: ui/gfx/geometry/point_f.h

Issue 1464603003: Use std::tie() for operator< in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/geometry/point.h ('k') | ui/gfx/paint_vector_icon.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_GEOMETRY_POINT_F_H_ 5 #ifndef UI_GFX_GEOMETRY_POINT_F_H_
6 #define UI_GFX_GEOMETRY_POINT_F_H_ 6 #define UI_GFX_GEOMETRY_POINT_F_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <string> 9 #include <string>
10 #include <tuple>
10 11
11 #include "ui/gfx/geometry/point.h" 12 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/geometry/vector2d_f.h" 13 #include "ui/gfx/geometry/vector2d_f.h"
13 #include "ui/gfx/gfx_export.h" 14 #include "ui/gfx/gfx_export.h"
14 15
15 namespace gfx { 16 namespace gfx {
16 17
17 // A floating version of gfx::Point. 18 // A floating version of gfx::Point.
18 class GFX_EXPORT PointF { 19 class GFX_EXPORT PointF {
19 public: 20 public:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 57
57 Vector2dF OffsetFromOrigin() const { return Vector2dF(x_, y_); } 58 Vector2dF OffsetFromOrigin() const { return Vector2dF(x_, y_); }
58 59
59 // A point is less than another point if its y-value is closer 60 // A point is less than another point if its y-value is closer
60 // to the origin. If the y-values are the same, then point with 61 // to the origin. If the y-values are the same, then point with
61 // the x-value closer to the origin is considered less than the 62 // the x-value closer to the origin is considered less than the
62 // other. 63 // other.
63 // This comparison is required to use PointF in sets, or sorted 64 // This comparison is required to use PointF in sets, or sorted
64 // vectors. 65 // vectors.
65 bool operator<(const PointF& rhs) const { 66 bool operator<(const PointF& rhs) const {
66 return (y_ == rhs.y_) ? (x_ < rhs.x_) : (y_ < rhs.y_); 67 return std::tie(y_, x_) < std::tie(rhs.y_, rhs.x_);
67 } 68 }
68 69
69 void Scale(float scale) { 70 void Scale(float scale) {
70 Scale(scale, scale); 71 Scale(scale, scale);
71 } 72 }
72 73
73 void Scale(float x_scale, float y_scale) { 74 void Scale(float x_scale, float y_scale) {
74 SetPoint(x() * x_scale, y() * y_scale); 75 SetPoint(x() * x_scale, y() * y_scale);
75 } 76 }
76 77
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 118 }
118 119
119 // This is declared here for use in gtest-based unit tests but is defined in 120 // This is declared here for use in gtest-based unit tests but is defined in
120 // the gfx_test_support target. Depend on that to use this in your unit test. 121 // the gfx_test_support target. Depend on that to use this in your unit test.
121 // This should not be used in production code - call ToString() instead. 122 // This should not be used in production code - call ToString() instead.
122 void PrintTo(const PointF& point, ::std::ostream* os); 123 void PrintTo(const PointF& point, ::std::ostream* os);
123 124
124 } // namespace gfx 125 } // namespace gfx
125 126
126 #endif // UI_GFX_GEOMETRY_POINT_F_H_ 127 #endif // UI_GFX_GEOMETRY_POINT_F_H_
OLDNEW
« no previous file with comments | « ui/gfx/geometry/point.h ('k') | ui/gfx/paint_vector_icon.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698