Goals for Better Code - Implement Complete Types

CppNow · 9K views · 2014 · 1:32:48

Open on YouTube

C, C++, Rust, Go & systems languagesSoftware architecture & designtalk

Why Stack Overflow recommends it

Stack Overflow users link it when discussing copy-and-swap, move semantics and a related C++ defect report, citing Parent's explanation at about 44 minutes.

Recommended by 1 people across 1 different months, 2015 to 2020.

What it is

A 1h32m talk by Sean Parent at C++Now 2014, part of his 'Goals for Better Code' series, on making C++ types complete: regular, with correct copy, move, assignment and equality semantics. It is a conference presentation with code examples and design guidance.

What people said

Recommends alfC · 2020-04 · Stack Overflow · on “How can pointers be totally ordered?”

I think there is a deeper concept missing from this discussion, that is that of the pointer provenance . In principle you cannot compare pointers in general but you should be able to compare pointer that come (by arithmetic operations) from the same one. For example, pointers coming from a black box like different calls to new , cannot be compared reliably. (Here comparison applies to ordering but I guess strictly speaking it is also equality that is ill defined in this context, I am not sure. This would cover the mmap case above.) So, here is my attempt of a (rather useless but conceptual) answer: comparison of pointers is total order in the domain of applicability of the order operator (i.

Cites user362515 · 2015-02 · Stack Overflow · on “What is the copy-and-swap idiom?”

There is one more (massive) con. As of current specs *technically* the object will *not have an move-assignment operator!* If later used as member of a class, the new class *will not have move-ctor auto-generated!* Source: [this video]

Cites SCFrench · 2015-08 · Stack Overflow · on “What defect report is Sean Parent referring to in his GBC - Implement Complete Types talk”

In Sean Parent's talk Goals for Better Coding - implement Complete Types [this video] at 44:10-44:50 Sean says something to the effect of If I put this [class with a copy assignment operator that accepts its parameter by value, and also has a move constructor] as a member of another class, that other class will not get a default move constructor because the language in the spec does not say "if it is move constructable" it says "has a move constructor with this signature". There is a defect on it, I don't know [what it is] off the top of my head. Can anyone point me to the actual defect report that Sean is referring to?