Subject: Re: [boost] [core] Determining interest for two new classes: readonly and newtype
From: Darren Cook (darren_at_[hidden])
Date: 2015-08-16 13:47:21
> This is a wrapper class for a type to replace a const-type field in a
> movable class. It has const access to the type so can't modify except for
> the move constructor and move assignment operator.
> This solves the problem that no fields in a movable class can be const
> which can cloud the intentions of a field.
This reminded me of something I hit recently: I wanted to have a bunch
of fields to be const, but in one constructor I needed to initialize
them in the constructor body, not in the initializer list.
This created two problems. I thought I might be able to get around the
first (of how to actually set them) by using casts; the second problem
was the compiler warnings that I was not initializing all const members.
I couldn't work that one out, so I gave up and removed const from all of
Would your readonly<T> have helped me here? (And, conversely, if it
could, that implies the compiler cannot warn when they are not initialized?)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk