Subject: [std-proposals] Make lifetime a part of the object model
From: Omer Rosler (omer.rosler_at_[hidden])
Date: 2019-07-29 16:43:39
I want your feedback about the merit of what I want to propose.
If the feedback will be positive, I will split these into separate papers
regarding every point below.
Will the committee be open to such a change?
The TL;DR is as follows:
- Bake an ownership model into the language as an opt-in mechanism
using the (placeholder) keyword `*unique*`
- This allows us *language level RAII*
- This model adds *zero-runtime overhead* (no extra pointers are
- This turns many *dangling* references/pointer bugs into *compile
- Add `*restrict*` keyword to handle objects we don't own (it is
mostly backward compatible with C)
- Make copy/move elision mandatory in more cases (*guaranteed NRVO* and
Ultimate Copy Elision) by withhold conversion of owner objects into viewer
- Make copy/move elision allowed in more cases.
- Turn `unique` into a full blown *cv-qualifer* which allows the
1. *Destructive moves* (move constructors taking a `unique T&&`).
2. *Lazy evaluation* by overloading operations on `unique`
3. *Smart references* by providing a conversion operator on a `unique`
this pointer into a different type which is not `unique` (this requires
several changes to overload resolution as well).
- *Integrate *these new keywords *implicitly *in certain places that
need to be discussed (just like the integration of move semantics into
existing C++ 03 code).
Attached a very rough draft of the functionality proposed:
STD-PROPOSALS list run by firstname.lastname@example.org
Standard Proposals Archives on Google Groups