修复vector当对象是std::string时的构造二义性bug
This commit is contained in:
@@ -90,7 +90,7 @@ namespace TinySTL{
|
||||
ForwardIterator _uninitialized_n_fill_aux(ForwardIterator first,
|
||||
Size n, const T& x, _false_type){
|
||||
int i = 0;
|
||||
for (; i != n;){
|
||||
for (; i != n; ++i){
|
||||
construct((first + i), x);
|
||||
}
|
||||
return (first + i);
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace TinySTL{
|
||||
private:
|
||||
void allocateAndFillN(const size_type n, const value_type& value){
|
||||
start_ = dataAllocator::allocate(n);
|
||||
uninitialized_fill_n(start_, n, value);
|
||||
TinySTL::uninitialized_fill_n(start_, n, value);
|
||||
finish_ = endOfStorage_ = start_ + n;
|
||||
}
|
||||
template<class InputIterator>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
#include "Allocator.h"
|
||||
#include "Construct.h"
|
||||
@@ -11,12 +12,8 @@
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
int array[3] = { 1, 2, 3 };
|
||||
TinySTL::vector<int> vec(array, array + 3);
|
||||
//TinySTL::vector<int> vec(3, 1); -> error C2019
|
||||
cout << *(vec.begin()) << endl;
|
||||
cout << *(++vec.begin()) << endl;
|
||||
cout << *(--vec.end()) << endl;
|
||||
TinySTL::vector<std::string> svec(10, "hello world");
|
||||
for (auto s : svec){ cout << s << endl; }
|
||||
system("pause");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user