// http://en.cppreference.com/w/cpp/container/list #include #include #include using namespace std; int main() { // Create a list containing integers list l = { 7, 5, 16, 8 }; // Add an integer to the front of the list l.push_front(25); // Add an integer to the back of the list l.push_back(13); // Insert an integer before 16 by searching auto it = find(l.begin(), l.end(), 16); if(it != l.end()) { l.insert(it, 42); } // Iterate and print values of the list for(int n : l) { cout << n << '\n'; } return 0; } // main()