Tell me what you think, especially tell me areas that are screwed up if you see them. And if you don't mind testing it that would be awesome. All around criticism again!
If I uncomment the other line in main I get compile errors:
1>myvector.h(151): error C3867: 'MyVector<T>::size': function call missing argument list;
use '&MyVector<T>::size' to create a pointer to member
where my guess was you meant to use either size() or size_.
You're also attempting to return NULL when the user attempts to access outside of bounds through operator[] and that obviously is not correct (and your comments there show you're aware of this.)
If I uncomment the other line in main I get compile errors:
Ah yup I meant size_, or size() really. Doesn't matter. I just missed that when I changed the naming I guess.
I have comments spread out about things I need to fix still, I was just working on a functional version first. I also still can't use this for types with no default constructor due to my allocate method, I'm working on that now. Wrong usage of new.
EDIT:
Should work with objects of no default ctor now. Check latest commit.
int main()
{
std::vector<int, MemoryManager<int> > v = {1,2,3,4,5};
}
with this error
c:\mingw32\bin\../lib/gcc/i686-pc-mingw32/4.7.2/../../../../include/c++/4.7.2/bits/stl_vector.h:175:4: error: no
matching function for call to 'std::_Vector_base<int, MemoryManager<int> >::_Vector_impl::deallocate(int*&, std::size_t&)'
I actually haven't been writing this as a replacement to std::vector, so I'm surprised it's even that close to being able to.
I'd assume that 5 was a typo. Changing that actually just made it functional. I have a test class being pushed into it 100000 time and it works pretty well. Takes a little bit of time though. It's actually pretty quick, nevermind. Had a bunch of debugging statements thrown in there slowing it down.
Thanks on the ::operator delete(). I actually wasn't sure what to do there, as my comment says.
Why do I need the second argument in deallocate()? What is it used for?