Using a forward_list to store int values - C++ STL

C++ examples for STL:forward_list

Description

Using a forward_list to store int values

Demo Code

#include <cinttypes>
#include <forward_list>
#include <iostream>

using namespace std;

int main(int argv, char* argc[])
{
    forward_list<int32_t> myList{ 1, 2, 3, 4, 5 };

    myList.emplace_front(6);/*  w  w w. ja  va  2s .  co m*/

    auto forwardIter = myList.begin();
    ++forwardIter;
    ++forwardIter;
    myList.emplace_after(forwardIter, 9);

    for (auto&& number : myList)
    {
        cout << number << endl;
    }

    return 0;
}

Result


Related Tutorials