Skip to content

Instantly share code, notes, and snippets.

@rue
Created September 13, 2008 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rue/10536 to your computer and use it in GitHub Desktop.
Save rue/10536 to your computer and use it in GitHub Desktop.
#include <list>
#include <iostream>
#include <iterator>
int main()
{
std::list<int> l;
std::list<int>::iterator i1 = l.insert(l.end(), 1);
std::list<int>::iterator i2 = l.insert(l.end(), 2);
std::list<int>::iterator i3 = l.insert(l.end(), 3);
std::cout << l.size() << std::endl << std::endl;
std::cout << std::endl;
std::cout << *i1 << std::endl;
std::cout << *i2 << std::endl;
std::cout << *i3 << std::endl;
l.erase(i2);
std::cout << std::endl << l.size() << std::endl << std::endl;
std::cout << *i1 << std::endl;
std::cout << *i3 << std::endl;
std::cout << std::endl;
// This is neat, by the way
std::copy(l.begin(), l.end(), std::ostream_iterator<int>(std::cout, " "));
std::cout << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment