From 47d39d86052a5807573b203743f3348182d67cf8 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 13 Nov 2020 13:46:13 +0000 Subject: [PATCH] Fixed warnings --- include/etl/variant.h | 556 +++++++++++++++++++++--------------------- 1 file changed, 278 insertions(+), 278 deletions(-) diff --git a/include/etl/variant.h b/include/etl/variant.h index 8909e754..f0a20158 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -390,282 +390,6 @@ namespace etl void read(no_type8&) {}; }; - //************************************************************************* - //**** Up-cast functors *************************************************** - //************************************************************************* - - //************************************************************************* - /// Base upcast_functor for eight types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - case 2: return reinterpret_cast(*p_data); - case 3: return reinterpret_cast(*p_data); - case 4: return reinterpret_cast(*p_data); - case 5: return reinterpret_cast(*p_data); - case 6: return reinterpret_cast(*p_data); - case 7: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - - const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - case 2: return reinterpret_cast(*p_data); - case 3: return reinterpret_cast(*p_data); - case 4: return reinterpret_cast(*p_data); - case 5: return reinterpret_cast(*p_data); - case 6: return reinterpret_cast(*p_data); - case 7: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - }; - - //************************************************************************* - /// Upcast_functor for seven types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - case 2: return reinterpret_cast(*p_data); - case 3: return reinterpret_cast(*p_data); - case 4: return reinterpret_cast(*p_data); - case 5: return reinterpret_cast(*p_data); - case 6: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - - const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - case 2: return reinterpret_cast(*p_data); - case 3: return reinterpret_cast(*p_data); - case 4: return reinterpret_cast(*p_data); - case 5: return reinterpret_cast(*p_data); - case 6: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - }; - - //************************************************************************* - /// Upcast_functor for six types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - case 2: return reinterpret_cast(*p_data); - case 3: return reinterpret_cast(*p_data); - case 4: return reinterpret_cast(*p_data); - case 5: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - - const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - case 2: return reinterpret_cast(*p_data); - case 3: return reinterpret_cast(*p_data); - case 4: return reinterpret_cast(*p_data); - case 5: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - }; - - //************************************************************************* - /// Upcast_functor for five types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - case 2: return reinterpret_cast(*p_data); - case 3: return reinterpret_cast(*p_data); - case 4: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - - const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - case 2: return reinterpret_cast(*p_data); - case 3: return reinterpret_cast(*p_data); - case 4: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - }; - - //************************************************************************* - /// Upcast_functor for four types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - case 2: return reinterpret_cast(*p_data); - case 3: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - - const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - case 2: return reinterpret_cast(*p_data); - case 3: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - }; - - //************************************************************************* - /// Upcast_functor for three types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - case 2: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - - const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - case 2: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - }; - - //************************************************************************* - /// Upcast_functor for two types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - - const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - case 1: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - }; - - //************************************************************************* - /// Upcast_functor for one type. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - - const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(*p_data); - default: return reinterpret_cast(*reinterpret_cast(0)); - } - } - }; - //*************************************************************************** /// The base type for derived readers. //*************************************************************************** @@ -963,7 +687,7 @@ namespace etl template TBase& upcast() { - return upcast_functor()(data, type_id); + return *upcast_functor()(data, type_id); } //*************************************************************************** @@ -973,7 +697,7 @@ namespace etl template const TBase& upcast() const { - return upcast_functor()(data, type_id); + return *upcast_functor()(data, type_id); } //*************************************************************************** @@ -1021,6 +745,282 @@ namespace etl type_id = UNSUPPORTED_TYPE_ID; } + //************************************************************************* + //**** Up-cast functors *************************************************** + //************************************************************************* + + //************************************************************************* + /// Base upcast_functor for eight types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + case 5: return reinterpret_cast(p_data); + case 6: return reinterpret_cast(p_data); + case 7: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + case 5: return reinterpret_cast(p_data); + case 6: return reinterpret_cast(p_data); + case 7: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for seven types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + case 5: return reinterpret_cast(p_data); + case 6: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + case 5: return reinterpret_cast(p_data); + case 6: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for six types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + case 5: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + case 5: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for five types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for four types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for three types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for two types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for one type. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + //*************************************************************************** /// The internal storage. /// Aligned on a suitable boundary, which should be good for all types.