添加非0断言

This commit is contained in:
邹晓航
2014-09-19 08:29:03 +08:00
parent 7edc0a6b7f
commit 0313b51ffb
3 changed files with 7 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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">

View File

@@ -32,5 +32,8 @@
<ClInclude Include="Allocator.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="UninitializedFunctions.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>