到达!我就是这样做的,但是有点长。还有更紧凑的吗?(我使用的是 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);
应该做的伎俩。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句