添加swap
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#define _QUEUE_H_
|
#define _QUEUE_H_
|
||||||
|
|
||||||
#include "Deque.h"
|
#include "Deque.h"
|
||||||
|
#include "Functional.h"
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
|
|
||||||
namespace TinySTL{
|
namespace TinySTL{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Allocator.h"
|
#include "Allocator.h"
|
||||||
#include "ReverseIterator.h"
|
#include "ReverseIterator.h"
|
||||||
#include "UninitializedFunctions.h"
|
#include "UninitializedFunctions.h"
|
||||||
|
#include "Utility.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@@ -122,9 +123,9 @@ namespace TinySTL{
|
|||||||
string& replace(iterator i1, iterator i2, InputIterator first, InputIterator last);
|
string& replace(iterator i1, iterator i2, InputIterator first, InputIterator last);
|
||||||
|
|
||||||
void swap(string& str){
|
void swap(string& str){
|
||||||
std::swap(start_, str.start_);
|
TinySTL::swap(start_, str.start_);
|
||||||
std::swap(finish_, str.finish_);
|
TinySTL::swap(finish_, str.finish_);
|
||||||
std::swap(endOfStorage_, str.endOfStorage_);
|
TinySTL::swap(endOfStorage_, str.endOfStorage_);
|
||||||
}
|
}
|
||||||
size_t copy(char* s, size_t len, size_t pos = 0) const{
|
size_t copy(char* s, size_t len, size_t pos = 0) const{
|
||||||
auto ptr = TinySTL::uninitialized_copy(begin() + pos, begin() + pos + len, s);
|
auto ptr = TinySTL::uninitialized_copy(begin() + pos, begin() + pos + len, s);
|
||||||
|
|||||||
@@ -99,6 +99,7 @@
|
|||||||
<ClInclude Include="String.h" />
|
<ClInclude Include="String.h" />
|
||||||
<ClInclude Include="TypeTraits.h" />
|
<ClInclude Include="TypeTraits.h" />
|
||||||
<ClInclude Include="UninitializedFunctions.h" />
|
<ClInclude Include="UninitializedFunctions.h" />
|
||||||
|
<ClInclude Include="Utility.h" />
|
||||||
<ClInclude Include="Vector.h" />
|
<ClInclude Include="Vector.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|||||||
@@ -77,5 +77,8 @@
|
|||||||
<ClInclude Include="Functional.h">
|
<ClInclude Include="Functional.h">
|
||||||
<Filter>头文件</Filter>
|
<Filter>头文件</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Utility.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
13
TinySTL/Utility.h
Normal file
13
TinySTL/Utility.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef _UTILITY_H_
|
||||||
|
#define _UTILITY_H_
|
||||||
|
|
||||||
|
namespace TinySTL{
|
||||||
|
//************ [swap] ***************
|
||||||
|
template<class T>
|
||||||
|
void swap(T& a, T& b){
|
||||||
|
T temp = a;
|
||||||
|
a = b;
|
||||||
|
b = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user