copy constructors need documentation

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Aug 5 23:25:48 UTC 2019


On Monday, August 5, 2019 7:33:19 AM MDT Olivier FAURE via Digitalmars-d 
wrote:
> On Monday, 5 August 2019 at 12:42:34 UTC, ag0aep6g wrote:
> > Or is there a good reason why the following shouldn't work?
>
> Well, it's a crime against understandable code and against reason
> itself, but it's not strictly *unsound* per se.

Really, it comes down to whether it's worth special-casing it to make it
illegal. The type system itself prevents a const or immutable opAssign from
doing something that they shouldn't (barring casts which involve undefined
behavior anyway), and realistically, no one is going to define them anyway.
So, while really, they shouldn't ever be declared, the fact that they can be
shouldn't actually be a problem.

- Jonathan M Davis





More information about the Digitalmars-d mailing list