c++ Programming Glossary: c.push_back
C++ Vector of Pointers to Objects http://stackoverflow.com/questions/1361139/c-vector-of-pointers-to-objects container void foo container c for unsigned i 0 i 100 i c.push_back new derived leaks here frees the pointers doesn't delete them.. delete ptr void foo container c for unsigned i 0 i 100 i c.push_back new derived free memory std for_each c.begin c.end delete_pointed_to.. container void foo container c for unsigned i 0 i 100 i c.push_back make_unique derived all automatically freed here int main foo..
Merge two STL vectors with an alternation pattern http://stackoverflow.com/questions/3660058/merge-two-stl-vectors-with-an-alternation-pattern std vector int const_iterator aIt a.begin aIt a.end aIt c.push_back aIt if c.size 1 STEP 0 c.push_back bIt bIt assume b is large.. a.begin aIt a.end aIt c.push_back aIt if c.size 1 STEP 0 c.push_back bIt bIt assume b is large enough The vector c now looks like..
Is it safe to push_back 'dynamically allocated object' to vector? http://stackoverflow.com/questions/4185350/is-it-safe-to-push-back-dynamically-allocated-object-to-vector void push_back_new Container c auto_ptr T p new T c.push_back p.get p.release Usage then isn't too tedious struct Bar Foo..
|