hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler
Other
5.27k stars 225 forks source link

New returns optional of owning reference #914

Open iprtel opened 6 months ago

iprtel commented 6 months ago

This patch represents a suggestion: Default new should return std::optional<owning_reference> with owning_reference managing the life time of the object in a similar way as a unique_ptr would with the exception that it is not allowed to be null.

This will allow to move the reference around without null checks.