DEV Community

Farhan Yahya
Farhan Yahya

Posted on • Edited on

4 1

The list::swap() function

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};
a.swap(b);
//from here the content of a is in b and vice-versa

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay