From 239b3ab10b460da34c490a7e06a21c984e21ffb6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 26 Nov 2021 20:21:12 +0000 Subject: Enable all Jason Turner recommended warnings --- lib/cache.h | 3 +++ lib/jsonParse-persistence.cpp | 9 +++++---- lib/jsonParse.impl.cpp | 20 ++++++++++---------- lib/maths.cpp | 4 ++-- lib/maths.h | 6 +++--- lib/persistence.h | 13 ++++++++++++- lib/ptr.hpp | 4 ++-- 7 files changed, 37 insertions(+), 22 deletions(-) (limited to 'lib') diff --git a/lib/cache.h b/lib/cache.h index 48b9c55..2a6e3e5 100644 --- a/lib/cache.h +++ b/lib/cache.h @@ -7,6 +7,9 @@ template class Cache { public: using Ptr = std::shared_ptr; + + virtual ~Cache() = default; + [[nodiscard]] Ptr get(const std::string & key) { diff --git a/lib/jsonParse-persistence.cpp b/lib/jsonParse-persistence.cpp index 5062796..a9b9a83 100644 --- a/lib/jsonParse-persistence.cpp +++ b/lib/jsonParse-persistence.cpp @@ -97,7 +97,7 @@ namespace Persistence { wrh(std::ostream & strm, char ch) { using namespace std::literals; - strm << R"(\u)"sv << std::setw(4) << std::hex << (int)ch << std::setw(1); + strm << R"(\u)"sv << std::setw(4) << std::hex << static_cast(ch) << std::setw(1); } static inline void wre(std::ostream & strm, char e) @@ -116,7 +116,7 @@ namespace Persistence { static constexpr OutFuncs outFuncs {[]() { OutFuncs outFuncs; outFuncs.fill(&wrv); - for (int x = 0; x < 0x20; x += 1) { + for (auto x = 0U; x < 0x20U; x += 1) { outFuncs[x] = &wrh; } outFuncs['\"'] = &wre<'"'>; @@ -160,7 +160,8 @@ namespace Persistence { strm << value; } - void JsonWritePersistence::pushValue(std::nullptr_t) const + void + JsonWritePersistence::pushValue(std::nullptr_t) const { strm << "null"; } @@ -170,7 +171,7 @@ namespace Persistence { { strm << '"'; std::for_each(value.begin(), value.end(), [this](char ch) { - outFuncs[(unsigned char)ch](strm, ch); + outFuncs[static_cast(ch)](strm, ch); }); strm << '"'; } diff --git a/lib/jsonParse.impl.cpp b/lib/jsonParse.impl.cpp index 0913847..ce1020f 100644 --- a/lib/jsonParse.impl.cpp +++ b/lib/jsonParse.impl.cpp @@ -19,24 +19,24 @@ void json::jsonParser::appendEscape(unsigned long cp, std::string & str) { if (cp <= 0x7F) { - str += (char)cp; + str += static_cast(cp); } else if (cp <= 0x7FF) { - str += char((cp >> 6) + 192); - str += char((cp & 63) + 128); + str += static_cast((cp >> 6) + 192); + str += static_cast((cp & 63) + 128); } else if ((0xd800 <= cp && cp <= 0xdfff) || cp > 0x10FFFF) { throw std::range_error("Invalid UTF-8 sequence"); } else if (cp <= 0xFFFF) { - str += char((cp >> 12) + 224); - str += char(((cp >> 6) & 63) + 128); - str += char((cp & 63) + 128); + str += static_cast((cp >> 12) + 224); + str += static_cast(((cp >> 6) & 63) + 128); + str += static_cast((cp & 63) + 128); } else { - str += char((cp >> 18) + 240); - str += char(((cp >> 12) & 63) + 128); - str += char(((cp >> 6) & 63) + 128); - str += char((cp & 63) + 128); + str += static_cast((cp >> 18) + 240); + str += static_cast(((cp >> 12) & 63) + 128); + str += static_cast(((cp >> 6) & 63) + 128); + str += static_cast((cp & 63) + 128); } } diff --git a/lib/maths.cpp b/lib/maths.cpp index e894d02..4d9f8d4 100644 --- a/lib/maths.cpp +++ b/lib/maths.cpp @@ -173,10 +173,10 @@ find_arcs_radius(glm::vec2 start, glm::vec2 ad, glm::vec2 end, glm::vec2 bd) float operator"" _mph(const long double v) { - return mph_to_ms(v); + return static_cast(mph_to_ms(v)); } float operator"" _kph(const long double v) { - return kph_to_ms(v); + return static_cast(kph_to_ms(v)); } diff --git a/lib/maths.h b/lib/maths.h index 285c69a..18332b7 100644 --- a/lib/maths.h +++ b/lib/maths.h @@ -69,7 +69,7 @@ template inline constexpr auto rdiv(Ta a, Tb b) { - return ((R)a / (R)b); + return (static_cast(a) / static_cast(b)); } constexpr inline glm::vec2 @@ -105,14 +105,14 @@ float find_arcs_radius(glm::vec2 start, glm::vec2 ad, glm::vec2 end, glm::vec2 b // Conversions template -inline constexpr float +inline constexpr auto mph_to_ms(T v) { return v / 2.237; } template -inline constexpr float +inline constexpr auto kph_to_ms(T v) { return v / 3.6; diff --git a/lib/persistence.h b/lib/persistence.h index 252afde..0faa24d 100644 --- a/lib/persistence.h +++ b/lib/persistence.h @@ -26,6 +26,10 @@ namespace Persistence { using Stack = std::stack; struct Writer { + Writer() = default; + virtual ~Writer() = default; + DEFAULT_MOVE_COPY(Writer); + virtual void beginObject() const = 0; virtual void beginArray() const = 0; virtual void pushValue(bool value) const = 0; @@ -85,6 +89,7 @@ namespace Persistence { template struct SelectionT : public SelectionV { using SelectionV::SelectionV; + using Selection::setValue; using P = std::conditional_t, T, T &&>; void @@ -102,6 +107,8 @@ namespace Persistence { struct Persistable; struct PersistenceStore { + virtual ~PersistenceStore() = default; + template [[nodiscard]] inline bool persistType(const T * const, const std::type_info & ti); enum class NameAction { Push, HandleAndContinue, Ignore }; @@ -292,6 +299,7 @@ namespace Persistence { struct SelectionObj : public SelectionV { struct MakeObjectByTypeName : public SelectionV { using SelectionV::SelectionV; + using Selection::setValue; void setValue(std::string && type) override @@ -316,6 +324,7 @@ namespace Persistence { struct RememberObjectById : public SelectionV { using SelectionV::SelectionV; + using Selection::setValue; void setValue(std::string && id) override @@ -383,8 +392,10 @@ namespace Persistence { } using SelectionV::SelectionV; + using Selection::setValue; - void setValue(std::nullptr_t) override + void + setValue(std::nullptr_t) override { this->v.reset(); } diff --git a/lib/ptr.hpp b/lib/ptr.hpp index b92b63e..0b00285 100644 --- a/lib/ptr.hpp +++ b/lib/ptr.hpp @@ -16,9 +16,9 @@ public: template static auto - create(Obj * (*factory)(Args...), void (*deleter)(Obj *), Params &&... params) + create(Obj * (*factory)(Params...), void (*deleter)(Obj *), Args &&... args) { - return wrapped_ptr {factory(std::forward(params)...), deleter}; + return wrapped_ptr {factory(std::forward(args)...), deleter}; } }; -- cgit v1.2.3