diff --git a/drape_frontend/color_constants.cpp b/drape_frontend/color_constants.cpp index c3591e24c9..630d735df2 100644 --- a/drape_frontend/color_constants.cpp +++ b/drape_frontend/color_constants.cpp @@ -15,16 +15,14 @@ #include -using namespace std; - namespace { -string const kTransitColorFileName = "transit_colors.txt"; +std::string const kTransitColorFileName = "transit_colors.txt"; class TransitColorsHolder { public: - dp::Color GetColor(string const & name) const + dp::Color GetColor(std::string const & name) const { auto const style = GetStyleReader().GetCurrentStyle(); auto const isDarkStyle = style == MapStyle::MapStyleDark || style == MapStyle::MapStyleVehicleDark; @@ -37,7 +35,7 @@ public: void Load() { - string data; + std::string data; try { ReaderPtr(GetPlatform().GetReader(kTransitColorFileName)).ReadAsString(data); @@ -66,7 +64,7 @@ public: ASSERT(name != nullptr, ()); ASSERT(colorInfo != nullptr, ()); - string strValue; + std::string strValue; FromJSONObject(colorInfo, "clear", strValue); m_clearColors[df::GetTransitColorName(name)] = ParseColor(strValue); FromJSONObject(colorInfo, "night", strValue); @@ -82,10 +80,10 @@ public: } } - map const & GetClearColors() const { return m_clearColors; } + std::map const & GetClearColors() const { return m_clearColors; } private: - dp::Color ParseColor(string const & colorStr) + dp::Color ParseColor(std::string const & colorStr) { unsigned int color; if (strings::to_uint(colorStr, color, 16)) @@ -94,8 +92,8 @@ private: return dp::Color(); } - map m_clearColors; - map m_nightColors; + std::map m_clearColors; + std::map m_nightColors; }; TransitColorsHolder & TransitColors() @@ -130,7 +128,7 @@ dp::Color GetColorConstant(ColorConstant const & constant) return ToDrapeColor(color); } -map const & GetTransitClearColors() { return TransitColors().GetClearColors(); } +std::map const & GetTransitClearColors() { return TransitColors().GetClearColors(); } void LoadTransitColors() { diff --git a/drape_frontend/transit_scheme_builder.cpp b/drape_frontend/transit_scheme_builder.cpp index 4e3874e516..736eb85821 100644 --- a/drape_frontend/transit_scheme_builder.cpp +++ b/drape_frontend/transit_scheme_builder.cpp @@ -26,13 +26,11 @@ #include -using namespace std; - namespace df { -int const kTransitSchemeMinZoomLevel = 10; -float const kTransitLineHalfWidth = 0.8f; -std::array const kTransitLinesWidthInPixel = +int constexpr kTransitSchemeMinZoomLevel = 10; +float constexpr kTransitLineHalfWidth = 0.8f; +std::array constexpr kTransitLinesWidthInPixel = { // 1 2 3 4 5 6 7 8 9 10 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.25f, @@ -95,7 +93,7 @@ using TGeometryBuffer = std::vector; dp::BindingInfo const & GetTransitStaticBindingInfo() { - static unique_ptr s_info; + static std::unique_ptr s_info; if (s_info == nullptr) { dp::BindingFiller filler(3); diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index 17963162d8..f0529cd072 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -26,15 +26,13 @@ namespace df { -using namespace std; - namespace { -uint64_t const kDoubleTapPauseMs = 250; -uint64_t const kLongTouchMs = 500; -uint64_t const kKineticDelayMs = 500; +uint64_t constexpr kDoubleTapPauseMs = 250; +uint64_t constexpr kLongTouchMs = 500; +uint64_t constexpr kKineticDelayMs = 500; -float const kForceTapThreshold = 0.75; +float constexpr kForceTapThreshold = 0.75; size_t GetValidTouchesCount(std::array const & touches) { @@ -68,7 +66,7 @@ char const * UserEventStream::DOUBLE_TAP_AND_HOLD = "DoubleTapAndHold"; char const * UserEventStream::END_DOUBLE_TAP_AND_HOLD = "EndDoubleTapAndHold"; #endif -uint8_t const TouchEvent::INVALID_MASKED_POINTER = 0xFF; +uint8_t constexpr TouchEvent::INVALID_MASKED_POINTER = 0xFF; void TouchEvent::SetFirstTouch(const Touch & touch) { @@ -80,7 +78,7 @@ void TouchEvent::SetSecondTouch(const Touch & touch) m_touches[1] = touch; } -void TouchEvent::PrepareTouches(array const & previousTouches) +void TouchEvent::PrepareTouches(std::array const & previousTouches) { if (GetValidTouchesCount(m_touches) == 2 && GetValidTouchesCount(previousTouches) > 0) { @@ -126,7 +124,7 @@ void TouchEvent::Swap() return index ^ 0x1; }; - swap(m_touches[0], m_touches[1]); + std::swap(m_touches[0], m_touches[1]); SetFirstMaskedPointer(swapIndex(GetFirstMaskedPointer())); SetSecondMaskedPointer(swapIndex(GetSecondMaskedPointer())); } @@ -143,7 +141,7 @@ UserEventStream::UserEventStream() void UserEventStream::AddEvent(drape_ptr && event) { std::lock_guard guard(m_lock); - m_events.emplace_back(move(event)); + m_events.emplace_back(std::move(event)); } ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChanged, bool & viewportChanged) @@ -151,7 +149,7 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChanged, bool TEventsList events; { std::lock_guard guard(m_lock); - swap(m_events, events); + std::swap(m_events, events); } m2::RectD const prevPixelRect = GetCurrentScreen().PixelRect(); @@ -743,7 +741,7 @@ bool UserEventStream::ProcessTouch(TouchEvent const & touch) return isMapTouch; } -bool UserEventStream::TouchDown(array const & touches) +bool UserEventStream::TouchDown(std::array const & touches) { size_t touchCount = GetValidTouchesCount(touches); bool isMapTouch = true; @@ -803,12 +801,12 @@ bool UserEventStream::TouchDown(array const & touches) return isMapTouch; } -bool UserEventStream::CheckDrag(array const & touches, double threshold) const +bool UserEventStream::CheckDrag(std::array const & touches, double threshold) const { return m_startDragOrg.SquaredLength(m2::PointD(touches[0].m_location)) > threshold; } -bool UserEventStream::TouchMove(array const & touches) +bool UserEventStream::TouchMove(std::array const & touches) { size_t const touchCount = GetValidTouchesCount(touches); bool isMapTouch = true; @@ -890,7 +888,7 @@ bool UserEventStream::TouchMove(array const & touches) return isMapTouch; } -bool UserEventStream::TouchCancel(array const & touches) +bool UserEventStream::TouchCancel(std::array const & touches) { size_t touchCount = GetValidTouchesCount(touches); UNUSED_VALUE(touchCount); @@ -931,7 +929,7 @@ bool UserEventStream::TouchCancel(array const & touches) return isMapTouch; } -bool UserEventStream::TouchUp(array const & touches) +bool UserEventStream::TouchUp(std::array const & touches) { size_t touchCount = GetValidTouchesCount(touches); bool isMapTouch = true; @@ -988,7 +986,7 @@ bool UserEventStream::TouchUp(array const & touches) return isMapTouch; } -void UserEventStream::UpdateTouches(array const & touches) +void UserEventStream::UpdateTouches(std::array const & touches) { m_touches = touches; } diff --git a/drape_frontend/user_mark_shapes.cpp b/drape_frontend/user_mark_shapes.cpp index c6da65080d..81d90a8bd1 100644 --- a/drape_frontend/user_mark_shapes.cpp +++ b/drape_frontend/user_mark_shapes.cpp @@ -29,7 +29,7 @@ namespace df { namespace { -std::array const kLineWidthZoomFactor = +std::array constexpr kLineWidthZoomFactor = { // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 0.3, 0.3, 0.3, 0.4, 0.5, 0.6, 0.7, 0.7, 0.7, 0.7, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0