DEV Community


The list::swap() function

dochan profile image Farhan Yahya Updated on ・1 min read

The list swap function is used in c++ to swap the values of two lists with the same size and type.

std::list<int> a{1, 2, 3, 4, 5};
std::list<int> b{6, 7, 8, 9, 10};
//from here the content of a is in b and vice-versa

Discussion (0)

Forem Open with the Forem app