Const initialization issue, looking for solution
Maxim Fomin
maxim at maxim-fomin.ru
Wed May 29 06:51:36 PDT 2013
On Wednesday, 29 May 2013 at 13:44:15 UTC, Jakob Ovrum wrote:
> On Wednesday, 29 May 2013 at 13:35:18 UTC, Maxim Fomin wrote:
>> It is not casting away const and it has nothing to do with
>> immutable, also this does not suffer from data was actually
>> immutable problem.
>
> The data is not initially constructed by the local function,
> it's clearly coming from somewhere else and there's no
> guarantee that it's not returning a const view of immutable
> data. The code is not limited to accepting const, of course,
> and exhibits the same problem when the function returns
> immutable data.
>
> Unions are a convenience feature, it boils down to the same as
> a cast and has the same problems (actually worse because the
> conversion is not explicit).
If you accept const object as a parameter, then yes.
More information about the Digitalmars-d
mailing list