๐Ÿ› ๏ธ Steven Gong

Search

SearchSearch
Feb 11, 2026 ยท 1 min read ยท 35 views ยท 1 in the last 30 days

Where readers are reading from

FijiTanzaniaWestern SaharaCanada ยท 0 readersUnited States of America ยท 0 readersKazakhstanUzbekistanPapua New GuineaIndonesiaArgentinaChileDemocratic Republic of the CongoSomaliaKenyaSudanChadHaitiDominican RepublicRussiaThe BahamasFalkland IslandsNorwayGreenlandFrench Southern and Antarctic LandsEast TimorSouth AfricaLesothoMexicoUruguayBrazilBoliviaPeruColombiaPanamaCosta RicaNicaraguaHondurasEl SalvadorGuatemalaBelizeVenezuelaGuyanaSurinameFranceEcuadorPuerto RicoJamaicaCubaZimbabweBotswanaNamibiaSenegalMaliMauritaniaBeninNigerNigeriaCameroonTogoGhanaIvory CoastGuineaGuinea-BissauLiberiaSierra LeoneBurkina FasoCentral African RepublicRepublic of the CongoGabonEquatorial GuineaZambiaMalawiMozambiqueEswatiniAngolaBurundiIsraelLebanonMadagascarPalestineThe GambiaTunisiaAlgeriaJordanUnited Arab EmiratesQatarKuwaitIraqOmanVanuatuCambodiaThailandLaosMyanmarVietnam ยท 0 readersNorth KoreaSouth KoreaMongoliaIndiaBangladeshBhutanNepalPakistanAfghanistanTajikistanKyrgyzstanTurkmenistanIranSyriaArmeniaSwedenBelarusUkrainePolandAustriaHungaryMoldovaRomaniaLithuaniaLatviaEstoniaGermanyBulgariaGreeceTurkeyAlbaniaCroatiaSwitzerlandLuxembourgBelgiumNetherlandsPortugalSpainIrelandNew CaledoniaSolomon IslandsNew ZealandAustraliaSri LankaPeople's Republic of China ยท 0 readersTaiwanItalyDenmarkUnited KingdomIcelandAzerbaijanGeorgiaPhilippinesMalaysiaBruneiSloveniaFinlandSlovakiaCzech RepublicEritreaJapanParaguayYemenSaudi ArabiaTurkish Republic of Northern CyprusCyprusMorocco ยท 0 readersEgyptLibyaEthiopiaDjiboutiSomalilandUgandaRwandaBosnia and HerzegovinaNorth MacedoniaSerbiaMontenegroKosovoTrinidad and TobagoSouth SudanSelect a country to explore ยท Last 30 days
Singapore2
China0
Canada0
United States0
Bahrain0
Morocco0
Traffic ยท last 30 days000Sep 25Oct 5Oct 15Oct 24
views
Traffic ยท all time122May 25May 28May 31Jun 3Jun 5
views

Copy-and-Swap Idiom

Learned in CS247.

We use the Copy-and-Swap Idiom to address potential code duplication between copy constructor and copy assignment operator.

Used in the Copy Assignment Operator (after copy constructor is implemented)

Node& Node::operator=(const Node& other) {
	Node tmp{other};
	std::swap(data, tmp.data);
	std::swap(next, tmp.next);
	return *this;
}

There may be memory leaks here!

https://stackoverflow.com/questions/3279543/what-is-the-copy-and-swap-idiom

Graph View

Backlinks

  • CS247 - Software Engineering Principles
  • Copy Assignment Operator
  • Copy-and-Swap Idiom
  • Copy-on-Write Idiom
  • Exception Safety

Created with Quartz, ยฉ 2026

  • Blog
  • LinkedIn
  • Twitter
  • GitHub