From eb636b7c686f33b45a21e8d06fe9773e2fb5994c Mon Sep 17 00:00:00 2001 From: Victor Derks Date: Wed, 16 Apr 2025 21:50:03 +0200 Subject: [PATCH] Update C++ language to C++20 --- .gitignore | 16 +--------------- Directory.Build.props | 30 ++++++++++-------------------- include/msf/context_menu_impl.h | 4 ++-- include/msf/global_lock.h | 4 +--- include/msf/shell_ext_init_impl.h | 2 +- include/msf/shell_folder_impl.h | 27 +++++++++++++-------------- msf.sln.DotSettings | 2 ++ 7 files changed, 30 insertions(+), 55 deletions(-) diff --git a/.gitignore b/.gitignore index d2b3aba..d88c6ce 100644 --- a/.gitignore +++ b/.gitignore @@ -2,24 +2,10 @@ # User-specific files *.suo # Ignore Visual Studio User option files -*.v12.suo *.user -*.userosscache -*.sln.docstates - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile -*.opendb -*.db # Build results -[Bb]in/ -Intermediate/ +build/ .vs/ .vscode/ diff --git a/Directory.Build.props b/Directory.Build.props index a968e63..51d7e8c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,10 +2,12 @@ - $(MSBuildThisFileDirectory)bin\$(Configuration)\$(Platform)\ + $(MSBuildThisFileDirectory)build\bin\$(Configuration)\$(Platform)\ + $(MSBuildThisFileDirectory)build\bin\x86\$(Configuration)\ - $(MSBuildThisFileDirectory)intermediate\$(MSBuildProjectName)\$(Platform)\$(Configuration)\ + $(MSBuildThisFileDirectory)build\intermediate\$(MSBuildProjectName)\$(Platform)\$(Configuration)\ + $(MSBuildThisFileDirectory)build\intermediate\$(MSBuildProjectName)\x86\$(Configuration)\ 10 @@ -24,7 +26,7 @@ true - stdcpp17 + stdcpp20 true @@ -39,7 +41,7 @@ utf-8 = interpret all source files as UTF-8 (Required as MSVC relies on UTF-8 signature, which is not used) ZH:SHA_256 = Use an SHA-256 hash for the checksum.in debug info --> - /Zc:__cplusplus /Zc:throwingNew /utf-8 /ZH:SHA_256 + /Zc:__cplusplus /Zc:throwingNew /utf-8 /ZH:SHA_256 %(AdditionalOptions) EnableAllWarnings @@ -73,9 +75,7 @@ C5045 = Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified --> - /wd4061 /wd4191 - /wd4263 /wd4264 /wd4265 /wd4266 - /wd4365 + /wd4061 /wd4191 /wd4263 /wd4264 /wd4265 /wd4266 /wd4365 /wd4464 /wd4514 /wd4571 /wd4599 /wd4623 /wd4625 /wd4626 /wd4668 @@ -93,19 +93,9 @@ _ATL_NO_HOSTING = will prevent that ATL headers including mshtml.h, which is not strictStrings compatible. --> - WIN32; - _WINDOWS; - WIN32_LEAN_AND_MEAN; - NOMINMAX; - _ATL_EX_CONVERSION_MACROS_ONLY; - _ATL_CSTRING_EXPLICIT_CONSTRUCTORS; - _ATL_ALL_WARNINGS; - _ATL_ALL_USER_WARNINGS; - _ATL_ENABLE_PTM_WARNING; - _ATL_NO_AUTOMATIC_NAMESPACE; - _ATL_CCOMBSTR_EXPLICIT_CONSTRUCTORS; - _ATL_NO_HOSTING; - _CSTRING_DISABLE_NARROW_WIDE_CONVERSION; + WIN32;_WINDOWS;WIN32_LEAN_AND_MEAN;NOMINMAX;_ATL_EX_CONVERSION_MACROS_ONLY;_ATL_CSTRING_EXPLICIT_CONSTRUCTORS; + _ATL_ALL_WARNINGS;_ATL_ALL_USER_WARNINGS;_ATL_ENABLE_PTM_WARNING;_ATL_NO_AUTOMATIC_NAMESPACE; + _ATL_CCOMBSTR_EXPLICIT_CONSTRUCTORS;_ATL_NO_HOSTING;_CSTRING_DISABLE_NARROW_WIDE_CONVERSION; %(PreprocessorDefinitions) diff --git a/include/msf/context_menu_impl.h b/include/msf/context_menu_impl.h index 5a91ee6..34ff67e 100644 --- a/include/msf/context_menu_impl.h +++ b/include/msf/context_menu_impl.h @@ -97,13 +97,13 @@ class __declspec(novtable) ContextMenuImpl : return AddSubMenu(LoadResourceString(nIDText).c_str(), LoadResourceString(nIDHelp).c_str()); } - // Purpose: create and add a owner drawn custom sub menu to the context menu. + // Purpose: create and add an owner drawn custom sub menu to the context menu. Menu AddSubMenu(std::wstring strHelp, std::unique_ptr customMenuHandler) { auto subMenu = CreateSubMenu(); MenuItemInfo menuiteminfo(*m_pidCmd, subMenu); customMenuHandler->InitializeItemInfo(menuiteminfo); - InsertMenuItem(menuiteminfo, std::move(strHelp), std::move(std::unique_ptr(nullptr)), std::move(customMenuHandler)); + InsertMenuItem(menuiteminfo, std::move(strHelp), std::unique_ptr(nullptr), std::move(customMenuHandler)); return Menu(subMenu, 0, *m_pidCmd, m_idCmdLast, m_menuHost); } diff --git a/include/msf/global_lock.h b/include/msf/global_lock.h index 34388f8..c53e420 100644 --- a/include/msf/global_lock.h +++ b/include/msf/global_lock.h @@ -7,8 +7,7 @@ #include "msf_base.h" -namespace msf { -namespace util { +namespace msf::util { template class GlobalLock final @@ -76,4 +75,3 @@ class GlobalLock final }; } -} diff --git a/include/msf/shell_ext_init_impl.h b/include/msf/shell_ext_init_impl.h index ed85f76..ea7455e 100644 --- a/include/msf/shell_ext_init_impl.h +++ b/include/msf/shell_ext_init_impl.h @@ -67,7 +67,7 @@ class IShellExtInitImpl : public IShellExtInit bool ContainsUnknownExtension(const std::vector& filenames) const { return std::find_if(filenames.begin(), filenames.end(), - [=](const std::wstring& fileName) { return IsUnknownExtension(fileName); }) != filenames.end(); + [this](const std::wstring& fileName) { return IsUnknownExtension(fileName); }) != filenames.end(); } bool IsUnknownExtension(const std::wstring& fileName) const diff --git a/include/msf/shell_folder_impl.h b/include/msf/shell_folder_impl.h index 8d3a929..7303c65 100644 --- a/include/msf/shell_folder_impl.h +++ b/include/msf/shell_folder_impl.h @@ -37,17 +37,16 @@ struct __declspec(uuid("93F81976-6A0D-42C3-94DD-AA258A155470")) IShellUndocument struct __declspec(uuid("CAD9AE9F-56E2-40F1-AFB6-3813E320DCFD")) IShellUndocumentedCA; // Seen on Windows 8 template -class __declspec(novtable) ShellFolderImpl : - public IPersistFolder3, - public IPersistIDList, - public IShellDetails, - public IShellFolder2, - public IObjectWithFolderEnumMode, - public IShellIcon, - public IDropTarget, - public IShellFolderContextMenuSink, - public IPerformedDropEffectSink, - public IExplorerPaneVisibility +class __declspec(novtable) ShellFolderImpl : public IPersistFolder3, + public IPersistIDList, + public IShellDetails, + public IShellFolder2, + public IObjectWithFolderEnumMode, + public IShellIcon, + public IDropTarget, + public IShellFolderContextMenuSink, + public IPerformedDropEffectSink, + public IExplorerPaneVisibility { public: enum class ErrorContext @@ -862,7 +861,7 @@ class __declspec(novtable) ShellFolderImpl : // Purpose: Called by shell/MSF through the CompareItems function. // MSF will compare column by column. // Override this function if needed. - int CompareIDsAllFields(const TItem& item1, const TItem& item2) const noexcept + [[nodiscard]] int CompareIDsAllFields(const TItem& item1, const TItem& item2) const noexcept { int nResult = 0; // if there are no columns, items are always equal. @@ -1012,7 +1011,7 @@ class __declspec(novtable) ShellFolderImpl : ATLTRACE(L"ShellFolderImpl::OnDfmInvokeCommand 'DFM_CMD_PASTE'\n"); return static_cast(this)->OnDfmCmdPaste(window, dataObject); - case DFM_CMD_LINK: //DFM_CMD_CREATESHORTCUT: + case DFM_CMD_LINK: // DFM_CMD_CREATESHORTCUT: ATLTRACE(L"ShellFolderImpl::OnDfmInvokeCommand 'DFM_CMD_CREATESHORTCUT'\n"); return static_cast(this)->OnDfmCmdCreateShortcut(window, dataObject); @@ -1263,7 +1262,7 @@ class __declspec(novtable) ShellFolderImpl : const ATL::CComPtr shellfolderviewcb = static_cast(this)->CreateShellFolderViewCB(); - SFV_CREATE shellFolderViewCreate{sizeof(SFV_CREATE), this, nullptr, shellfolderviewcb}; + const SFV_CREATE shellFolderViewCreate{sizeof(SFV_CREATE), this, nullptr, shellfolderviewcb}; ATL::CComPtr shellView; RaiseExceptionIfFailed(SHCreateShellFolderView(&shellFolderViewCreate, &shellView)); diff --git a/msf.sln.DotSettings b/msf.sln.DotSettings index f4dc0d1..a05b21d 100644 --- a/msf.sln.DotSettings +++ b/msf.sln.DotSettings @@ -47,6 +47,7 @@ True True True + True True True True @@ -76,6 +77,7 @@ True True True + True True True True