diff --git a/TinySTL/UninitializedFunctions.h b/TinySTL/UninitializedFunctions.h index 21eb9f3..1bb4d5c 100644 --- a/TinySTL/UninitializedFunctions.h +++ b/TinySTL/UninitializedFunctions.h @@ -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); diff --git a/TinySTL/Vector.h b/TinySTL/Vector.h index 646f364..412c8ee 100644 --- a/TinySTL/Vector.h +++ b/TinySTL/Vector.h @@ -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 diff --git a/TinySTL/main.cpp b/TinySTL/main.cpp index cb4b453..aabf459 100644 --- a/TinySTL/main.cpp +++ b/TinySTL/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "Allocator.h" #include "Construct.h" @@ -11,12 +12,8 @@ using namespace std; int main(){ - int array[3] = { 1, 2, 3 }; - TinySTL::vector vec(array, array + 3); - //TinySTL::vector vec(3, 1); -> error C2019 - cout << *(vec.begin()) << endl; - cout << *(++vec.begin()) << endl; - cout << *(--vec.end()) << endl; + TinySTL::vector svec(10, "hello world"); + for (auto s : svec){ cout << s << endl; } system("pause"); return 0; -} \ No newline at end of file +}