添加非0断言
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "Alloc.h"
|
||||
#include "Construct.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <new>
|
||||
|
||||
namespace TinySTL{
|
||||
@@ -38,6 +39,7 @@ namespace TinySTL{
|
||||
}
|
||||
template<class T>
|
||||
T *allocator<T>::allocate(size_t n){
|
||||
assert(n != 0);
|
||||
return static_cast<T *>(alloc::allocate(sizeof(T) * n));
|
||||
}
|
||||
template<class T>
|
||||
@@ -46,6 +48,7 @@ namespace TinySTL{
|
||||
}
|
||||
template<class T>
|
||||
void allocator<T>::deallocate(T *ptr, size_t n){
|
||||
assert(n != 0);
|
||||
alloc::deallocate(static_cast<void *>(ptr), sizeof(T)* n);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<ClInclude Include="Allocator.h" />
|
||||
<ClInclude Include="Construct.h" />
|
||||
<ClInclude Include="TypeTraits.h" />
|
||||
<ClInclude Include="UninitializedFunctions.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
@@ -32,5 +32,8 @@
|
||||
<ClInclude Include="Allocator.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="UninitializedFunctions.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user