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

Side by Side Diff: ui/gfx/geometry/point.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/app_list/views/apps_grid_view.h ('k') | ui/gfx/geometry/point_f.h » ('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_H_ 5 #ifndef UI_GFX_GEOMETRY_POINT_H_
6 #define UI_GFX_GEOMETRY_POINT_H_ 6 #define UI_GFX_GEOMETRY_POINT_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/vector2d.h" 12 #include "ui/gfx/geometry/vector2d.h"
12 #include "ui/gfx/gfx_export.h" 13 #include "ui/gfx/gfx_export.h"
13 14
14 #if defined(OS_WIN) 15 #if defined(OS_WIN)
15 typedef unsigned long DWORD; 16 typedef unsigned long DWORD;
16 typedef struct tagPOINT POINT; 17 typedef struct tagPOINT POINT;
17 #elif defined(OS_MACOSX) 18 #elif defined(OS_MACOSX)
18 typedef struct CGPoint CGPoint; 19 typedef struct CGPoint CGPoint;
19 #endif 20 #endif
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 77
77 Vector2d OffsetFromOrigin() const { return Vector2d(x_, y_); } 78 Vector2d OffsetFromOrigin() const { return Vector2d(x_, y_); }
78 79
79 // A point is less than another point if its y-value is closer 80 // A point is less than another point if its y-value is closer
80 // to the origin. If the y-values are the same, then point with 81 // to the origin. If the y-values are the same, then point with
81 // the x-value closer to the origin is considered less than the 82 // the x-value closer to the origin is considered less than the
82 // other. 83 // other.
83 // This comparison is required to use Point in sets, or sorted 84 // This comparison is required to use Point in sets, or sorted
84 // vectors. 85 // vectors.
85 bool operator<(const Point& rhs) const { 86 bool operator<(const Point& rhs) const {
86 return (y_ == rhs.y_) ? (x_ < rhs.x_) : (y_ < rhs.y_); 87 return std::tie(y_, x_) < std::tie(rhs.y_, rhs.x_);
87 } 88 }
88 89
89 // Returns a string representation of point. 90 // Returns a string representation of point.
90 std::string ToString() const; 91 std::string ToString() const;
91 92
92 private: 93 private:
93 int x_; 94 int x_;
94 int y_; 95 int y_;
95 }; 96 };
96 97
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 float y_scale); 138 float y_scale);
138 GFX_EXPORT Point ScaleToFlooredPoint(const Point& point, float x_scale); 139 GFX_EXPORT Point ScaleToFlooredPoint(const Point& point, float x_scale);
139 GFX_EXPORT Point ScaleToRoundedPoint(const Point& point, 140 GFX_EXPORT Point ScaleToRoundedPoint(const Point& point,
140 float x_scale, 141 float x_scale,
141 float y_scale); 142 float y_scale);
142 GFX_EXPORT Point ScaleToRoundedPoint(const Point& point, float x_scale); 143 GFX_EXPORT Point ScaleToRoundedPoint(const Point& point, float x_scale);
143 144
144 } // namespace gfx 145 } // namespace gfx
145 146
146 #endif // UI_GFX_GEOMETRY_POINT_H_ 147 #endif // UI_GFX_GEOMETRY_POINT_H_
OLDNEW
« no previous file with comments | « ui/app_list/views/apps_grid_view.h ('k') | ui/gfx/geometry/point_f.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698