From 25b2250c32c1881990718c7de7b87f33ab703e79 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 10 May 2017 18:51:52 +0300 Subject: [tidy] modernize-use-using --- src/mbgl/annotation/symbol_annotation_impl.hpp | 46 +++++++++++++++++++++----- src/mbgl/geometry/anchor.hpp | 2 +- src/mbgl/gl/debugging_extension.hpp | 14 ++++---- src/mbgl/sprite/sprite_atlas.hpp | 4 +-- src/mbgl/text/collision_tile.hpp | 8 ++--- src/mbgl/text/glyph.hpp | 13 ++++---- src/mbgl/text/glyph_range.hpp | 4 +-- src/mbgl/text/quads.cpp | 2 +- src/mbgl/text/quads.hpp | 2 +- src/mbgl/util/mat2.hpp | 2 +- 10 files changed, 63 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/mbgl/annotation/symbol_annotation_impl.hpp b/src/mbgl/annotation/symbol_annotation_impl.hpp index c9a99ffb8d..b5be4e9ed9 100644 --- a/src/mbgl/annotation/symbol_annotation_impl.hpp +++ b/src/mbgl/annotation/symbol_annotation_impl.hpp @@ -26,10 +26,6 @@ #include #pragma GCC diagnostic pop -// Make Boost Geometry aware of our LatLng type -BOOST_GEOMETRY_REGISTER_POINT_2D_CONST(mbgl::LatLng, double, boost::geometry::cs::cartesian, longitude(), latitude()) -BOOST_GEOMETRY_REGISTER_BOX(mbgl::LatLngBounds, mbgl::LatLng, southwest(), northeast()) - namespace mbgl { class AnnotationTileLayer; @@ -47,9 +43,42 @@ public: } // namespace mbgl -// Tell Boost Geometry how to access a std::shared_ptr object. namespace boost { namespace geometry { + +// Make Boost Geometry aware of our LatLng type +namespace traits { + +template<> struct tag { using type = point_tag; }; +template<> struct dimension : boost::mpl::int_<2> {}; +template<> struct coordinate_type { using type = double; }; +template<> struct coordinate_system { using type = boost::geometry::cs::cartesian; }; + +template<> struct access { static inline double get(mbgl::LatLng const& p) { return p.longitude(); } }; +template<> struct access { static inline double get(mbgl::LatLng const& p) { return p.latitude(); } }; + +template<> struct tag { using type = box_tag; }; +template<> struct point_type { using type = mbgl::LatLng; }; + +template +struct indexed_access +{ + using ct = coordinate_type::type; + static inline ct get(mbgl::LatLngBounds const& b) { return geometry::get(b.southwest()); } + static inline void set(mbgl::LatLngBounds& b, ct const& value) { geometry::set(b.southwest(), value); } +}; + +template +struct indexed_access +{ + using ct = coordinate_type::type; + static inline ct get(mbgl::LatLngBounds const& b) { return geometry::get(b.northeast()); } + static inline void set(mbgl::LatLngBounds& b, ct const& value) { geometry::set(b.northeast(), value); } +}; + +} // namespace traits + +// Tell Boost Geometry how to access a std::shared_ptr object. namespace index { template <> @@ -61,6 +90,7 @@ struct indexable> { } }; -} // end namespace index -} // end namespace geometry -} // end namespace boost +} // namespace index + +} // namespace geometry +} // namespace boost diff --git a/src/mbgl/geometry/anchor.hpp b/src/mbgl/geometry/anchor.hpp index 3ed2b23e1b..b24d8d04e0 100644 --- a/src/mbgl/geometry/anchor.hpp +++ b/src/mbgl/geometry/anchor.hpp @@ -17,6 +17,6 @@ public: : point(x_, y_), angle(angle_), scale(scale_), segment(segment_) {} }; -typedef std::vector Anchors; +using Anchors = std::vector; } // namespace mbgl diff --git a/src/mbgl/gl/debugging_extension.hpp b/src/mbgl/gl/debugging_extension.hpp index c1835cfcdd..5657bbde88 100644 --- a/src/mbgl/gl/debugging_extension.hpp +++ b/src/mbgl/gl/debugging_extension.hpp @@ -53,13 +53,13 @@ namespace extension { class Debugging { public: - typedef void (*Callback)(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* message, - const void* userParam); + using Callback = void (*)(GLenum source, + GLenum type, + GLuint id, + GLenum severity, + GLsizei length, + const GLchar* message, + const void* userParam); static void DebugCallback(GLenum source, GLenum type, diff --git a/src/mbgl/sprite/sprite_atlas.hpp b/src/mbgl/sprite/sprite_atlas.hpp index 5afddaebce..5d99677726 100644 --- a/src/mbgl/sprite/sprite_atlas.hpp +++ b/src/mbgl/sprite/sprite_atlas.hpp @@ -38,8 +38,8 @@ public: float height; }; -typedef std::map IconMap; -typedef std::set IconDependencies; +using IconMap = std::map; +using IconDependencies = std::set; class IconRequestor { public: diff --git a/src/mbgl/text/collision_tile.hpp b/src/mbgl/text/collision_tile.hpp index ea4324edaf..653ea74489 100644 --- a/src/mbgl/text/collision_tile.hpp +++ b/src/mbgl/text/collision_tile.hpp @@ -28,10 +28,10 @@ namespace mbgl { namespace bg = boost::geometry; namespace bgm = bg::model; namespace bgi = bg::index; -typedef bgm::point CollisionPoint; -typedef bgm::box Box; -typedef std::tuple CollisionTreeBox; -typedef bgi::rtree> Tree; +using CollisionPoint = bgm::point; +using Box = bgm::box; +using CollisionTreeBox = std::tuple; +using Tree = bgi::rtree>; class IndexedSubfeature; diff --git a/src/mbgl/text/glyph.hpp b/src/mbgl/text/glyph.hpp index 9cf39de840..458cd688ad 100644 --- a/src/mbgl/text/glyph.hpp +++ b/src/mbgl/text/glyph.hpp @@ -13,8 +13,8 @@ namespace mbgl { -typedef char16_t GlyphID; -typedef std::set GlyphIDs; +using GlyphID = char16_t; +using GlyphIDs = std::set; // Note: this only works for the BMP GlyphRange getGlyphRange(GlyphID glyph); @@ -40,8 +40,8 @@ struct Glyph { GlyphMetrics metrics; }; -typedef std::map> GlyphPositions; -typedef std::map GlyphPositionMap; +using GlyphPositions = std::map>; +using GlyphPositionMap = std::map; class PositionedGlyph { public: @@ -97,8 +97,7 @@ constexpr WritingModeType operator~(WritingModeType value) { return WritingModeType(~mbgl::underlying_type(value)); } -typedef std::map GlyphDependencies; -typedef std::map GlyphRangeDependencies; - +using GlyphDependencies = std::map; +using GlyphRangeDependencies = std::map; } // end namespace mbgl diff --git a/src/mbgl/text/glyph_range.hpp b/src/mbgl/text/glyph_range.hpp index dd39e092b7..74afb73dfc 100644 --- a/src/mbgl/text/glyph_range.hpp +++ b/src/mbgl/text/glyph_range.hpp @@ -7,7 +7,7 @@ namespace mbgl { -typedef std::pair GlyphRange; +using GlyphRange = std::pair; struct GlyphRangeHash { std::size_t operator()(const GlyphRange& glyphRange) const { @@ -15,7 +15,7 @@ struct GlyphRangeHash { } }; -typedef std::unordered_set GlyphRangeSet; +using GlyphRangeSet = std::unordered_set; constexpr uint32_t GLYPHS_PER_GLYPH_RANGE = 256; constexpr uint32_t GLYPH_RANGES_PER_FONT_STACK = 256; diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 02236b1b89..6f13331d4c 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -108,7 +108,7 @@ struct GlyphInstance { const float angle = 0.0f; }; -typedef std::vector GlyphInstances; +using GlyphInstances = std::vector; struct VirtualSegment { Point anchor; diff --git a/src/mbgl/text/quads.hpp b/src/mbgl/text/quads.hpp index 333000627b..38dad95243 100644 --- a/src/mbgl/text/quads.hpp +++ b/src/mbgl/text/quads.hpp @@ -49,7 +49,7 @@ public: WritingModeType writingMode; }; -typedef std::vector SymbolQuads; +using SymbolQuads = std::vector; SymbolQuad getIconQuad(const Anchor& anchor, const PositionedIcon& shapedIcon, diff --git a/src/mbgl/util/mat2.hpp b/src/mbgl/util/mat2.hpp index 6a25ef0f1e..c463202daa 100644 --- a/src/mbgl/util/mat2.hpp +++ b/src/mbgl/util/mat2.hpp @@ -26,7 +26,7 @@ namespace mbgl { -typedef std::array mat2; +using mat2 = std::array; namespace matrix { -- cgit v1.2.1