From 2658bc66b8b68212594c71f7b51199921c3c1df9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 23 Sep 2017 19:22:18 +0200 Subject: use std::size --- compat/util.hpp | 3 ++- tracker-aruco/ftnoir_tracker_aruco.cpp | 2 +- tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp | 2 +- tracker-hatire/ftnoir_tracker_hat.cpp | 2 +- tracker-pt/ftnoir_tracker_pt_dialog.cpp | 3 +-- tracker-s2bot/ftnoir_tracker_s2bot.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compat/util.hpp b/compat/util.hpp index 2dcc3a2a..811f2c1d 100644 --- a/compat/util.hpp +++ b/compat/util.hpp @@ -11,7 +11,8 @@ #include #include -#include +#include + #include #define progn(...) (([&]() { __VA_ARGS__ })()) diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp index 962d0060..2842a9c2 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.cpp +++ b/tracker-aruco/ftnoir_tracker_aruco.cpp @@ -351,7 +351,7 @@ void aruco_tracker::cycle_detection_params() use_otsu = false; adaptive_size_pos++; - adaptive_size_pos %= sizeof(adaptive_sizes)/sizeof(*adaptive_sizes); + adaptive_size_pos %= std::size(adaptive_sizes); } set_detector_params(); diff --git a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp index 3f717682..6985032c 100644 --- a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp +++ b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp @@ -95,7 +95,7 @@ void tracker_freepie::run() { const int axis = order[i]; const int add_idx = add_indices[i]; int add = 0; - if (add_idx >= 0 && add_idx < (int)(sizeof(add_cbx) / sizeof(*add_cbx))) + if (add_idx >= 0 && add_idx < (int)std::size(add_cbx)) add = add_cbx[add_idx]; pose[Yaw + i] = r2d * orient[axis] + add; } diff --git a/tracker-hatire/ftnoir_tracker_hat.cpp b/tracker-hatire/ftnoir_tracker_hat.cpp index ca28ae84..6e1b6586 100644 --- a/tracker-hatire/ftnoir_tracker_hat.cpp +++ b/tracker-hatire/ftnoir_tracker_hat.cpp @@ -144,7 +144,7 @@ void hatire::data(double *data) { s.EnableRoll, s.InvertRoll, HAT.Rot[s.RollAxis], data[Roll] }, }; - for (unsigned i = 0; i < sizeof(spec) / sizeof(*spec); i++) + for (unsigned i = 0; i < std::size(spec); i++) { auto& k = spec[i]; k.place = (k.sign ? -1.f : 1.f) * (k.enable ? k.input : 0.f); diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp index fa159d34..2f554cbf 100644 --- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp +++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp @@ -88,8 +88,7 @@ TrackerDialog_PT::TrackerDialog_PT() pt_color_red_only, }; - static constexpr unsigned color_type_sz = sizeof(color_types) / sizeof(*color_types); - for (unsigned k = 0; k < color_type_sz; k++) + for (unsigned k = 0; k < std::size(color_types); k++) ui.blob_color->setItemData(k, int(color_types[k])); tie_setting(s.blob_color, ui.blob_color); diff --git a/tracker-s2bot/ftnoir_tracker_s2bot.cpp b/tracker-s2bot/ftnoir_tracker_s2bot.cpp index 88362aa4..6621e605 100644 --- a/tracker-s2bot/ftnoir_tracker_s2bot.cpp +++ b/tracker-s2bot/ftnoir_tracker_s2bot.cpp @@ -73,7 +73,7 @@ void tracker_s2bot::run() { const int axis = order[i]; const int add_idx = add_indices[i]; int add = 0; - if (add_idx >= 0 && add_idx < (int)(sizeof(add_cbx) / sizeof(*add_cbx))) + if (add_idx >= 0 && add_idx < (int)std::size(add_cbx)) add = add_cbx[add_idx]; pose[Yaw + i] = orient[axis] + add; // * r2d if it was radians } -- cgit v1.2.3