diff --git a/Allocator.h b/Allocator.h index 75a9384..a389bda 100644 --- a/Allocator.h +++ b/Allocator.h @@ -37,7 +37,6 @@ class MemoryPool Buffer *firstBuffer = nullptr; std::size_t bufferedBlocks = growSize; - public: MemoryPool() = default; @@ -82,7 +81,7 @@ class MemoryPool template class Allocator : private MemoryPool { -#ifdef _WIN32 +#if defined(_WIN32) && defined(ENABLE_OLD_WIN32_SUPPORT) Allocator *copyAllocator = nullptr; std::allocator *rebindAllocator = nullptr; #endif @@ -103,7 +102,7 @@ class Allocator : private MemoryPool typedef Allocator other; }; -#ifdef _WIN32 +#if defined(_WIN32) && defined(ENABLE_OLD_WIN32_SUPPORT) Allocator() = default; Allocator(Allocator &allocator) : @@ -126,7 +125,7 @@ class Allocator : private MemoryPool pointer allocate(size_type n, const void *hint = 0) { -#ifdef _WIN32 +#if defined(_WIN32) && defined(ENABLE_OLD_WIN32_SUPPORT) if (copyAllocator) return copyAllocator->allocate(n, hint); @@ -142,7 +141,7 @@ class Allocator : private MemoryPool void deallocate(pointer p, size_type n) { -#ifdef _WIN32 +#if defined(_WIN32) && defined(ENABLE_OLD_WIN32_SUPPORT) if (copyAllocator) { copyAllocator->deallocate(p, n); return; diff --git a/Allocator.sln b/Allocator.sln index 3d48610..7b91acc 100644 --- a/Allocator.sln +++ b/Allocator.sln @@ -1,31 +1,31 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27428.2027 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Allocator", "Allocator.vcxproj", "{35A51081-1318-4884-B394-D2DEC9415601}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {35A51081-1318-4884-B394-D2DEC9415601}.Debug|x64.ActiveCfg = Debug|x64 - {35A51081-1318-4884-B394-D2DEC9415601}.Debug|x64.Build.0 = Debug|x64 - {35A51081-1318-4884-B394-D2DEC9415601}.Debug|x86.ActiveCfg = Debug|Win32 - {35A51081-1318-4884-B394-D2DEC9415601}.Debug|x86.Build.0 = Debug|Win32 - {35A51081-1318-4884-B394-D2DEC9415601}.Release|x64.ActiveCfg = Release|x64 - {35A51081-1318-4884-B394-D2DEC9415601}.Release|x64.Build.0 = Release|x64 - {35A51081-1318-4884-B394-D2DEC9415601}.Release|x86.ActiveCfg = Release|Win32 - {35A51081-1318-4884-B394-D2DEC9415601}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {2F72DF30-C240-45A0-9CDE-E33186A20AB1} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2027 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Allocator", "Allocator.vcxproj", "{35A51081-1318-4884-B394-D2DEC9415601}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {35A51081-1318-4884-B394-D2DEC9415601}.Debug|x64.ActiveCfg = Debug|x64 + {35A51081-1318-4884-B394-D2DEC9415601}.Debug|x64.Build.0 = Debug|x64 + {35A51081-1318-4884-B394-D2DEC9415601}.Debug|x86.ActiveCfg = Debug|Win32 + {35A51081-1318-4884-B394-D2DEC9415601}.Debug|x86.Build.0 = Debug|Win32 + {35A51081-1318-4884-B394-D2DEC9415601}.Release|x64.ActiveCfg = Release|x64 + {35A51081-1318-4884-B394-D2DEC9415601}.Release|x64.Build.0 = Release|x64 + {35A51081-1318-4884-B394-D2DEC9415601}.Release|x86.ActiveCfg = Release|Win32 + {35A51081-1318-4884-B394-D2DEC9415601}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2F72DF30-C240-45A0-9CDE-E33186A20AB1} + EndGlobalSection +EndGlobal diff --git a/Allocator.vcxproj b/Allocator.vcxproj index b6e4465..83f67fa 100644 --- a/Allocator.vcxproj +++ b/Allocator.vcxproj @@ -1,153 +1,157 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {35A51081-1318-4884-B394-D2DEC9415601} - Allocator - 10.0.16299.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - $(VC_IncludePath);$(WindowsSDK_IncludePath);Allocator - $(SolutionDir)Build\$(Platform)_$(Configuration)\Intermediate\ - $(SolutionDir)Build\$(Platform)_$(Configuration)\ - - - $(VC_IncludePath);$(WindowsSDK_IncludePath);Allocator - $(SolutionDir)Build\$(Platform)_$(Configuration)\Intermediate\ - $(SolutionDir)Build\$(Platform)_$(Configuration)\ - - - $(VC_IncludePath);$(WindowsSDK_IncludePath);Allocator - $(SolutionDir)Build\$(Platform)_$(Configuration)\ - $(SolutionDir)Build\$(Platform)_$(Configuration)\Intermediate\ - - - $(VC_IncludePath);$(WindowsSDK_IncludePath);Allocator - $(SolutionDir)Build\$(Platform)_$(Configuration)\ - $(SolutionDir)Build\$(Platform)_$(Configuration)\Intermediate\ - - - - Level3 - Disabled - true - true - - - Console - - - - - Level3 - Disabled - true - true - - - Console - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - Console - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - Console - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {35A51081-1318-4884-B394-D2DEC9415601} + Allocator + 10.0 + + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + $(VC_IncludePath);$(WindowsSDK_IncludePath);Allocator + $(SolutionDir)Build\$(Platform)_$(Configuration)\Intermediate\ + $(SolutionDir)Build\$(Platform)_$(Configuration)\ + + + $(VC_IncludePath);$(WindowsSDK_IncludePath);Allocator + $(SolutionDir)Build\$(Platform)_$(Configuration)\Intermediate\ + $(SolutionDir)Build\$(Platform)_$(Configuration)\ + + + $(VC_IncludePath);$(WindowsSDK_IncludePath);Allocator + $(SolutionDir)Build\$(Platform)_$(Configuration)\ + $(SolutionDir)Build\$(Platform)_$(Configuration)\Intermediate\ + + + $(VC_IncludePath);$(WindowsSDK_IncludePath);Allocator + $(SolutionDir)Build\$(Platform)_$(Configuration)\ + $(SolutionDir)Build\$(Platform)_$(Configuration)\Intermediate\ + + + + Level3 + Disabled + true + true + stdcpp14 + + + Console + + + + + Level3 + Disabled + true + true + stdcpp14 + + + Console + + + + + Level3 + MaxSpeed + true + true + true + true + stdcpp14 + + + true + true + Console + + + + + Level3 + MaxSpeed + true + true + true + true + stdcpp14 + + + true + true + Console + + + + + + + + + + + + \ No newline at end of file diff --git a/Measure.cpp b/Measure.cpp index fde0c35..6744adb 100644 --- a/Measure.cpp +++ b/Measure.cpp @@ -18,7 +18,6 @@ class PerformanceTest { virtual void testIteration(size_t newSize) = 0; - protected: Container container; @@ -26,7 +25,6 @@ class PerformanceTest std::default_random_engine randomNumberGenerator; std::uniform_int_distribution randomNumberDistribution; - public: PerformanceTest() : diff --git a/README.md b/README.md index b973a48..68fae4f 100644 --- a/README.md +++ b/README.md @@ -79,9 +79,13 @@ Whole memory is allocated on heap and will be released when container is destroy ## MSVC support -Unfortunately since the very first release of the Allocator MS has changed twice their implementation of STL -allocator support. As the changes are very odd and requires some workarounds whose slows down the allocator I finally -decided to separate MSVC support from the original code with use of preprocessor. +After a recent test under Microsoft Visual Studio Community 2022 all the test passed successfully without any +extraordinary workarounds. To enable support for older versions of MSVC please define a `ENABLE_OLD_WIN32_SUPPORT` +constant. + +In older versions MS has changed twice their implementation of STL allocator support. The changes were very odd +and required some workarounds which slows down the allocator. My decision was to separate MSVC support from +the original code with use of a preprocessor. ### Workaround to the first MSVC update