C++ std::swap function in C++ In this article, we have explained the use of std::swap function in C++ with multiple C++ code examples covering primitive data types to User defined classes.