From b79cec3f8ffba98c48727868a8485f295305874c Mon Sep 17 00:00:00 2001 From: William Miles Date: Mon, 28 Nov 2022 17:51:31 +1100 Subject: [PATCH] Disabled unused variable and fallthrough warnings from std. Changed Store to be a template with tag that is used with a using declaration. --- Navmesher/esx_reader.hpp | 32 ++++++++++++++++++-------------- Navmesher/main.cpp | 4 ++++ Navmesher/utility.hpp | 14 ++++++++------ 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/Navmesher/esx_reader.hpp b/Navmesher/esx_reader.hpp index c48b5a9..4b8bd50 100644 --- a/Navmesher/esx_reader.hpp +++ b/Navmesher/esx_reader.hpp @@ -1,6 +1,9 @@ #ifndef ESX_READER_HPP #define ESX_READER_HPP +#pragma warning( push ) +#pragma warning( disable : 5264 ) +#pragma warning( disable : 5262 ) #include #include #include @@ -9,6 +12,7 @@ #include #include #include +#pragma warning( pop ) #include "utility.hpp" @@ -58,10 +62,10 @@ enum class RecordType { // Aggregate types // -struct FourCC : utility::Store { }; -struct FormID : utility::Store { }; -struct Timestamp : utility::Store { }; -struct VCInfo : utility::Store { }; +using FourCC = utility::Store; +using FormID = utility::Store; +using Timestamp = utility::Store; +using VCInfo = utility::Store; struct Flag { RecordType type; @@ -85,14 +89,14 @@ struct GroupHeader { int16_t y, x; }; - struct TopType : utility::Store { }; - struct ParentWorld : utility::Store { }; - struct BlockNumber : utility::Store { }; - struct SubBlockNumber : utility::Store { }; - struct BlockCoord : utility::Store { }; - struct SubBlockCoord : utility::Store { }; - struct ParentCell : utility::Store { }; - struct ParentDialogue : utility::Store { }; + using TopType = utility::Store; + using ParentWorld = utility::Store; + using BlockNumber = utility::Store; + using SubBlockNumber = utility::Store; + using BlockCoord = utility::Store; + using SubBlockCoord = utility::Store; + using ParentCell = utility::Store; + using ParentDialogue = utility::Store; union GroupLabel { TopType top_type; @@ -115,8 +119,8 @@ struct GroupHeader { }; struct RecordHeader { - struct Flags : utility::Store { }; - struct Version : utility::Store { }; + using Flags = utility::Store; + using Version = utility::Store; FourCC type; uint32_t size; diff --git a/Navmesher/main.cpp b/Navmesher/main.cpp index f88034f..f9fe064 100644 --- a/Navmesher/main.cpp +++ b/Navmesher/main.cpp @@ -1,8 +1,12 @@ #include "esx_reader.hpp" +#pragma warning( push ) +#pragma warning( disable : 5264 ) +#pragma warning( disable : 5262 ) #include #include #include +#pragma warning( pop ) static constexpr auto esx_name = "Skyrim.esm"; diff --git a/Navmesher/utility.hpp b/Navmesher/utility.hpp index 292aacf..81aea5f 100644 --- a/Navmesher/utility.hpp +++ b/Navmesher/utility.hpp @@ -1,9 +1,13 @@ #ifndef UTILITY_HPP #define UTILITY_HPP +#pragma warning( push ) +#pragma warning( disable : 5264 ) +#pragma warning( disable : 5262 ) #include #include #include +#pragma warning( pop ) namespace utility { @@ -15,12 +19,10 @@ T::size_type index_of(const T &container, typename T::const_iterator &iter) return static_cast(distance); } -// This is a base class for a generic store for some value that can be represented by -// type Type but should not be type checked as type Type, but rather some more constrained class. -// CRTP is the derived class, and is used as a tag to prevent having Store as a base class to -// multiple derived types. -template -struct Store { +// Along the lines of https://github.com/joboccara/NamedType +// Usage: using StoreType = Store; +template +struct Store final { static_assert(std::is_trivial_v); Type value; friend constexpr auto operator<=>(const Store &, const Store &) = default;