Issue with const
Steven Schveighoffer
schveiguy at yahoo.com
Mon Apr 9 08:30:33 PDT 2012
On Mon, 09 Apr 2012 11:22:54 -0400, Jacob Carlborg <doob at me.com> wrote:
> On 2012-04-09 16:52, Timon Gehr wrote:
>> On 04/09/2012 04:49 PM, Jacob Carlborg wrote:
>>>
>>> But now when I compile this code I get this error:
>>>
>>> Error: cannot implicitly convert expression (this.data) of type
>>> const(void*) to void*
>>>
>>> Any idea how to solve this? Or would I need to drop const.
>>>
>>> --
>>> /Jacob Carlborg
>>
>> Either clone the data too or use inout.
>
> Where would I use inout, on "clone"?
>
// untested
inout(Foo) clone() inout {
return new inout(Foo)(data);
}
Note, you can't post-assign data, since inout is effectively const inside
an inout function.
-Steve
More information about the Digitalmars-d-learn
mailing list