๐Ÿ› ๏ธ Steven Gong

Search

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

Where readers are reading from

FijiTanzaniaWestern SaharaCanada ยท 0 readersUnited States of America ยท 6 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 Kingdom ยท 1 readersIcelandAzerbaijanGeorgiaPhilippinesMalaysiaBruneiSloveniaFinlandSlovakiaCzech RepublicEritreaJapanParaguayYemenSaudi ArabiaTurkish Republic of Northern CyprusCyprusMorocco ยท 0 readersEgyptLibyaEthiopiaDjiboutiSomalilandUgandaRwandaBosnia and HerzegovinaNorth MacedoniaSerbiaMontenegroKosovoTrinidad and TobagoSouth SudanSelect a country to explore ยท Last 30 days
United States6
United Kingdom1
China0
Singapore0
Canada0
Bahrain0
Traffic ยท last 30 days012Nov 6Nov 16Nov 26Dec 5
views
Traffic ยท all time134May 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