MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / swap

Method swap

Exercises/Modules/Chapter 18/Soln18_01/Truckload.cpp:77–81  ·  view source on GitHub ↗

Swap assignment operator (noexcept + move-and-swap of course!)

Source from the content-addressed store, hash-verified

75
76// Swap assignment operator (noexcept + move-and-swap of course!)
77void Truckload::swap(Truckload& other) noexcept
78{
79 std::swap(m_head, other.m_head);
80 std::swap(m_tail, other.m_tail);
81}
82
83// Optional yet conventional non-member function (forwards to member function)
84void swap(Truckload& one, Truckload& other) noexcept

Callers 1

swapFunction · 0.45

Calls 1

swapFunction · 0.70

Tested by

no test coverage detected