diff --git a/CMakeLists.txt b/CMakeLists.txt
index 93560951..467fad95 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -187,7 +187,6 @@ install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_dir})
install(FILES include/mimalloc.h DESTINATION ${mi_install_dir}/include)
install(FILES include/mimalloc-override.h DESTINATION ${mi_install_dir}/include)
install(FILES include/mimalloc-new-delete.h DESTINATION ${mi_install_dir}/include)
-install(FILES include/mimalloc-stl-allocator.h DESTINATION ${mi_install_dir}/include)
install(FILES cmake/mimalloc-config.cmake DESTINATION ${mi_install_dir}/cmake)
install(FILES cmake/mimalloc-config-version.cmake DESTINATION ${mi_install_dir}/cmake)
install(EXPORT mimalloc DESTINATION ${mi_install_dir}/cmake)
diff --git a/ide/vs2017/mimalloc-override.vcxproj b/ide/vs2017/mimalloc-override.vcxproj
index e0a6d85b..863195a3 100644
--- a/ide/vs2017/mimalloc-override.vcxproj
+++ b/ide/vs2017/mimalloc-override.vcxproj
@@ -214,7 +214,6 @@
-
diff --git a/ide/vs2017/mimalloc.vcxproj b/ide/vs2017/mimalloc.vcxproj
index ff6c8edb..064a13dc 100644
--- a/ide/vs2017/mimalloc.vcxproj
+++ b/ide/vs2017/mimalloc.vcxproj
@@ -239,7 +239,6 @@
-
diff --git a/ide/vs2019/mimalloc-override.vcxproj b/ide/vs2019/mimalloc-override.vcxproj
index e6416e05..950a0a1a 100644
--- a/ide/vs2019/mimalloc-override.vcxproj
+++ b/ide/vs2019/mimalloc-override.vcxproj
@@ -214,7 +214,6 @@
-
diff --git a/ide/vs2019/mimalloc.vcxproj b/ide/vs2019/mimalloc.vcxproj
index ffede6ca..17adc958 100644
--- a/ide/vs2019/mimalloc.vcxproj
+++ b/ide/vs2019/mimalloc.vcxproj
@@ -239,7 +239,6 @@
-
diff --git a/include/mimalloc-stl-allocator.h b/include/mimalloc-stl-allocator.h
deleted file mode 100644
index a98e398b..00000000
--- a/include/mimalloc-stl-allocator.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#pragma once
-#ifndef MIMALLOC_STL_ALLOCATOR_H
-#define MIMALLOC_STL_ALLOCATOR_H
-
-#ifdef __cplusplus
-/* ----------------------------------------------------------------------------
-This header can be used to hook mimalloc into STL containers in place of
-std::allocator.
------------------------------------------------------------------------------*/
-#include // true_type
-
-#pragma warning(disable: 4100)
-
-template
-struct mi_stl_allocator {
- typedef T value_type;
-
- using propagate_on_container_copy_assignment = std::true_type;
- using propagate_on_container_move_assignment = std::true_type;
- using propagate_on_container_swap = std::true_type;
- using is_always_equal = std::true_type;
-
- mi_stl_allocator() noexcept {}
- mi_stl_allocator(const mi_stl_allocator& other) noexcept {}
- template
- mi_stl_allocator(const mi_stl_allocator& other) noexcept {}
-
- T* allocate(size_t n, const void* hint = 0) {
- return (T*)mi_mallocn(n, sizeof(T));
- }
-
- void deallocate(T* p, size_t n) {
- mi_free(p);
- }
-};
-
-template
-bool operator==(const mi_stl_allocator& lhs, const mi_stl_allocator& rhs) noexcept { return true; }
-template
-bool operator!=(const mi_stl_allocator& lhs, const mi_stl_allocator& rhs) noexcept { return false; }
-
-#endif // __cplusplus
-#endif // MIMALLOC_STL_ALLOCATOR_H
diff --git a/include/mimalloc.h b/include/mimalloc.h
index 988a080d..e664b668 100644
--- a/include/mimalloc.h
+++ b/include/mimalloc.h
@@ -73,7 +73,7 @@ terms of the MIT license. A copy of the license can be found in the file
#include // bool
#ifdef __cplusplus
-#include
+#include // true_type
extern "C" {
#endif
@@ -328,5 +328,41 @@ mi_decl_export void* mi_new_aligned_nothrow(size_t n, size_t alignment) mi_attr_
}
#endif
+#ifdef __cplusplus
+
+// ------------------------------------------------------
+// STL allocator - an extension to hook mimalloc into STL
+// containers in place of std::allocator.
+// ------------------------------------------------------
+
+#pragma warning(disable: 4100)
+template
+struct mi_stl_allocator {
+ typedef T value_type;
+
+ using propagate_on_container_copy_assignment = std::true_type;
+ using propagate_on_container_move_assignment = std::true_type;
+ using propagate_on_container_swap = std::true_type;
+ using is_always_equal = std::true_type;
+
+ mi_stl_allocator() noexcept {}
+ mi_stl_allocator(const mi_stl_allocator& other) noexcept {}
+ template
+ mi_stl_allocator(const mi_stl_allocator& other) noexcept {}
+
+ T* allocate(size_t n, const void* hint = 0) {
+ return (T*)mi_mallocn(n, sizeof(T));
+ }
+
+ void deallocate(T* p, size_t n) {
+ mi_free(p);
+ }
+};
+
+template
+bool operator==(const mi_stl_allocator& lhs, const mi_stl_allocator& rhs) noexcept { return true; }
+template
+bool operator!=(const mi_stl_allocator& lhs, const mi_stl_allocator& rhs) noexcept { return false; }
+#endif
#endif
diff --git a/test/test-api.c b/test/test-api.c
index f93884d0..060efc44 100644
--- a/test/test-api.c
+++ b/test/test-api.c
@@ -32,7 +32,6 @@ we therefore test the API over various inputs. Please add more tests :-)
#include "mimalloc.h"
#include "mimalloc-internal.h"
-#include "mimalloc-stl-allocator.h"
// ---------------------------------------------------------------------------
// Test macros: CHECK(name,predicate) and CHECK_BODY(name,body)