diff --git a/TinySTL/Allocator.h b/TinySTL/Allocator.h index 0e70378..42caa8a 100644 --- a/TinySTL/Allocator.h +++ b/TinySTL/Allocator.h @@ -4,6 +4,7 @@ #include "Alloc.h" #include "Construct.h" +#include #include namespace TinySTL{ @@ -38,6 +39,7 @@ namespace TinySTL{ } template T *allocator::allocate(size_t n){ + assert(n != 0); return static_cast(alloc::allocate(sizeof(T) * n)); } template @@ -46,6 +48,7 @@ namespace TinySTL{ } template void allocator::deallocate(T *ptr, size_t n){ + assert(n != 0); alloc::deallocate(static_cast(ptr), sizeof(T)* n); } diff --git a/TinySTL/TinySTL.vcxproj b/TinySTL/TinySTL.vcxproj index 0be76d6..39e827c 100644 --- a/TinySTL/TinySTL.vcxproj +++ b/TinySTL/TinySTL.vcxproj @@ -83,6 +83,7 @@ + diff --git a/TinySTL/TinySTL.vcxproj.filters b/TinySTL/TinySTL.vcxproj.filters index ee4eeb0..657d1f1 100644 --- a/TinySTL/TinySTL.vcxproj.filters +++ b/TinySTL/TinySTL.vcxproj.filters @@ -32,5 +32,8 @@ 头文件 + + 头文件 + \ No newline at end of file