Arr! This is how I do it, but it's kinda long. Anything more compact? (I am using cpp 98!)
std::vector<Object> allObjs;
// ... allObjs gets filled ...
// Now get back a vector with only the first element in allObjs
std::vector<Object> justTheFirstElemOfObjs;
justTheFirstElemOfObjs.push_back(allObjs.front());
allObjs = justTheFirstElemOfObjs;
allObjs.resize(1); should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With