From ca3e76d226a8d51369d503bb195e72ec42d314a7 Mon Sep 17 00:00:00 2001 From: abitmore Date: Mon, 6 Apr 2020 15:16:12 +0000 Subject: [PATCH] Fix compiler warnings about static_variant --- include/fc/static_variant.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index 768231a..452b090 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -75,7 +75,7 @@ protected: void init_from_tag(tag_type tag) { FC_ASSERT( tag >= 0 ); - FC_ASSERT( tag < count() ); + FC_ASSERT( static_cast(tag) < count() ); _tag = tag; typelist::runtime::dispatch(list(), tag, [this](auto t) { using T = typename decltype(t)::type; @@ -269,7 +269,7 @@ public: template static typename visitor::result_type visit( tag_type tag, visitor& v, void* data ) { - FC_ASSERT( tag >= 0 && tag < count(), "Unsupported type ${tag}!", ("tag",tag) ); + FC_ASSERT( tag >= 0 && static_cast(tag) < count(), "Unsupported type ${tag}!", ("tag",tag) ); return typelist::runtime::dispatch(list(), tag, [&v, data](auto t) { return v(*reinterpret_cast(data)); }); @@ -278,7 +278,7 @@ public: template static typename visitor::result_type visit( tag_type tag, const visitor& v, void* data ) { - FC_ASSERT( tag >= 0 && tag < count(), "Unsupported type ${tag}!", ("tag",tag) ); + FC_ASSERT( tag >= 0 && static_cast(tag) < count(), "Unsupported type ${tag}!", ("tag",tag) ); return typelist::runtime::dispatch(list(), tag, [&v, data](auto t) { return v(*reinterpret_cast(data)); }); @@ -287,7 +287,7 @@ public: template static typename visitor::result_type visit( tag_type tag, visitor& v, const void* data ) { - FC_ASSERT( tag >= 0 && tag < count(), "Unsupported type ${tag}!", ("tag",tag) ); + FC_ASSERT( tag >= 0 && static_cast(tag) < count(), "Unsupported type ${tag}!", ("tag",tag) ); return typelist::runtime::dispatch(list(), tag, [&v, data](auto t) { return v(*reinterpret_cast(data)); }); @@ -296,18 +296,18 @@ public: template static typename visitor::result_type visit( tag_type tag, const visitor& v, const void* data ) { - FC_ASSERT( tag >= 0 && tag < count(), "Unsupported type ${tag}!", ("tag",tag) ); + FC_ASSERT( tag >= 0 && static_cast(tag) < count(), "Unsupported type ${tag}!", ("tag",tag) ); return typelist::runtime::dispatch(list(), tag, [&v, data](auto t) { return v(*reinterpret_cast(data)); }); } static constexpr size_t count() { return typelist::length(); } - void set_which( tag_type w ) { - FC_ASSERT( w >= 0 ); - FC_ASSERT( w < count() ); + void set_which( tag_type tag ) { + FC_ASSERT( tag >= 0 ); + FC_ASSERT( static_cast(tag) < count() ); clean(); - init_from_tag(w); + init_from_tag(tag); } tag_type which() const {return _tag;}