From 1962acad49b30415c11bf2d671d9861dd64649c0 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Thu, 23 Jun 2016 19:56:17 -0300 Subject: [PATCH] AP_Common: simplify ARRAY_SUBSCRIPT macro Add DEFINE prefix, since this macro is defining these operators and remove the parameter since we will always use it to access a union/struct as a byte array. --- libraries/AP_Common/AP_Common.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/libraries/AP_Common/AP_Common.h b/libraries/AP_Common/AP_Common.h index a642e91e78..efbecfd295 100644 --- a/libraries/AP_Common/AP_Common.h +++ b/libraries/AP_Common/AP_Common.h @@ -46,15 +46,9 @@ /* Declare and implement const and non-const versions of the array subscript * operator. The object is treated as an array of type_ values. */ -#define ARRAY_SUBSCRIPT(type_) \ -inline type_ &operator[](size_t i) \ -{ \ - return reinterpret_cast(this)[i]; \ -} \ -inline type_ operator[](size_t i) const \ -{ \ - return reinterpret_cast(this)[i]; \ -} +#define DEFINE_BYTE_ARRAY_METHODS \ + inline uint8_t &operator[](size_t i) { return reinterpret_cast(this)[i]; } \ + inline uint8_t operator[](size_t i) const { return reinterpret_cast(this)[i]; } #define LOCATION_ALT_MAX_M 83000 // maximum altitude (in meters) that can be fit into Location structure's alt field