Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STL on custom OS - std::list works, but std::vector doesn't

I'm just playing around with a grub-bootable C++ kernel in visual studio 2010.

I've gotten to the point where I have new and delete written and things such as dynamically allocated arrays work. I can use STL lists, for example. I can even sort them, after I wrote a memcpy routine. The problem is when I use the std::vector type. Simply constructing the vector sends the kernel off into la la land.

Obviously I'm missing a function implementation of some kind, but I looked through STL searching for it and came up empty-handed. It fails at the push_back:

vector<int> v;
v.push_back(1);

and disappears into the ether.

Any guesses as to what I'm missing?

Edit yes it's vector of int. Sorry for the confusion. Not only that, but it's not the constructor it fails on, it's a call to push_back.

like image 306
jjacksonRIAB Avatar asked Dec 16 '22 22:12

jjacksonRIAB


1 Answers

Stab in the dark: do you have new[] and delete[] implemented? A list will create one item at a time with new while a vector will likely allocate larger blocks of memory with new[].

like image 161
John Kugelman Avatar answered Jan 06 '23 01:01

John Kugelman