From baf4f45e65fa8f0414b0040a5c26c1ff3e1c3564 Mon Sep 17 00:00:00 2001 From: Double Sine Date: Tue, 15 Jan 2019 11:23:11 +0800 Subject: [PATCH] Move inline attribute inside struct --- navicat-patcher/ResourceGuard.hpp | 12 ++---------- navicat-patcher/ResourceGuardCapstone.hpp | 5 +---- navicat-patcher/ResourceGuardOpenssl.hpp | 20 ++++---------------- navicat-patcher/ResourceGuardWin32.hpp | 15 +++------------ 4 files changed, 10 insertions(+), 42 deletions(-) diff --git a/navicat-patcher/ResourceGuard.hpp b/navicat-patcher/ResourceGuard.hpp index dca7ccb..96a796d 100644 --- a/navicat-patcher/ResourceGuard.hpp +++ b/navicat-patcher/ResourceGuard.hpp @@ -86,27 +86,19 @@ public: template struct CppObjectTraits { using HandleType = __ClassType*; - static const HandleType InvalidValue; + static inline const HandleType InvalidValue = nullptr; static inline void Releasor(HandleType pObject) { delete pObject; } }; -template -inline const typename CppObjectTraits<__ClassType>::HandleType - CppObjectTraits<__ClassType>::InvalidValue = nullptr; - template struct CppDynamicArrayTraits { using HandleType = __ClassType*; - static const HandleType InvalidValue; + static inline const HandleType InvalidValue = nullptr; static inline void Releasor(HandleType pArray) { delete[] pArray; } }; -template -inline const typename CppDynamicArrayTraits<__ClassType>::HandleType - CppDynamicArrayTraits<__ClassType>::InvalidValue = nullptr; - diff --git a/navicat-patcher/ResourceGuardCapstone.hpp b/navicat-patcher/ResourceGuardCapstone.hpp index 5927651..a46f006 100644 --- a/navicat-patcher/ResourceGuardCapstone.hpp +++ b/navicat-patcher/ResourceGuardCapstone.hpp @@ -4,12 +4,9 @@ struct CapstoneHandleTraits { using HandleType = csh; - static const HandleType InvalidValue; + static inline const HandleType InvalidValue = 0; static inline void Releasor(csh Handle) { cs_close(&Handle); } }; -inline const CapstoneHandleTraits::HandleType - CapstoneHandleTraits::InvalidValue = 0; - diff --git a/navicat-patcher/ResourceGuardOpenssl.hpp b/navicat-patcher/ResourceGuardOpenssl.hpp index 22b1bcf..9f5f067 100644 --- a/navicat-patcher/ResourceGuardOpenssl.hpp +++ b/navicat-patcher/ResourceGuardOpenssl.hpp @@ -6,37 +6,25 @@ struct OpensslBIOTraits { using HandleType = BIO*; - static const HandleType InvalidValue; + static inline const HandleType InvalidValue = nullptr; static constexpr auto& Releasor = BIO_free; }; -inline const OpensslBIOTraits::HandleType - OpensslBIOTraits::InvalidValue = nullptr; - struct OpensslBIOChainTraits { using HandleType = BIO*; - static const HandleType InvalidValue; + static inline const HandleType InvalidValue = nullptr; static constexpr auto& Releasor = BIO_free_all; }; -inline const OpensslBIOChainTraits::HandleType - OpensslBIOChainTraits::InvalidValue = nullptr; - struct OpensslBNTraits { using HandleType = BIGNUM*; - static const HandleType InvalidValue; + static inline const HandleType InvalidValue = nullptr; static constexpr auto& Releasor = BN_free; }; -inline const OpensslBNTraits::HandleType - OpensslBNTraits::InvalidValue = nullptr; - struct OpensslRSATraits { using HandleType = RSA*; - static const HandleType InvalidValue; + static inline const HandleType InvalidValue = nullptr; static constexpr auto& Releasor = RSA_free; }; -inline const OpensslRSATraits::HandleType - OpensslRSATraits::InvalidValue = nullptr; - diff --git a/navicat-patcher/ResourceGuardWin32.hpp b/navicat-patcher/ResourceGuardWin32.hpp index 8317280..a527545 100644 --- a/navicat-patcher/ResourceGuardWin32.hpp +++ b/navicat-patcher/ResourceGuardWin32.hpp @@ -4,28 +4,19 @@ struct GenericHandleTraits { using HandleType = HANDLE; - static const HandleType InvalidValue; + static inline const HandleType InvalidValue = NULL; static constexpr auto& Releasor = CloseHandle; }; -inline const GenericHandleTraits::HandleType - GenericHandleTraits::InvalidValue = NULL; - struct FileHandleTraits { using HandleType = HANDLE; - static const HandleType InvalidValue; + static inline const HandleType InvalidValue = INVALID_HANDLE_VALUE; static constexpr auto& Releasor = CloseHandle; }; -inline const FileHandleTraits::HandleType - FileHandleTraits::InvalidValue = INVALID_HANDLE_VALUE; - struct MapViewTraits { using HandleType = PVOID; - static const HandleType InvalidValue; + static inline const HandleType InvalidValue = NULL; static constexpr auto& Releasor = UnmapViewOfFile; }; -inline const MapViewTraits::HandleType - MapViewTraits::InvalidValue = NULL; -