-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOperation2.cpp
52 lines (41 loc) · 1.14 KB
/
Operation2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* \file Operation2.cpp
* \brief
*
* \todo
*/
#include<iostream>
#include<forward_list>
using namespace std;
int main()
{
// Initializing forward list
forward_list<int> flist = {10, 20, 30} ;
// Declaring a forward list iterator
forward_list<int>::iterator ptr;
// Inserting value using insert_after()
// starts insertion from second position
ptr = flist.insert_after(flist.begin(), {1, 2, 3});
// Displaying the forward list
cout << "The forward list after insert_after operation : ";
for (int&c : flist)
cout << c << " ";
cout << endl;
// Inserting value using emplace_after()
// inserts 2 after ptr
ptr = flist.emplace_after(ptr,2);
// Displaying the forward list
cout << "The forward list after emplace_after operation : ";
for (int&c : flist)
cout << c << " ";
cout << endl;
// Deleting value using erase.after Deleted 2
// after ptr
ptr = flist.erase_after(ptr);
// Displaying the forward list
cout << "The forward list after erase_after operation : ";
for (int&c : flist)
cout << c << " ";
cout << endl;
return 0;
}