is my code to get CTFE instantiated object valid D ?
chmike via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat May 28 23:49:42 PDT 2016
On Saturday, 28 May 2016 at 21:21:34 UTC, ag0aep6g wrote:
> On 05/28/2016 09:54 PM, chmike wrote:
>> The only inconvenience left is that we can't have mutable
>> references
>> to immutable objects.
>
> There is std.typecons.Rebindable for that.
That would be a good news. What is the right way to use it ? I
had a hard time to understand how to use Rebindable.
Rebindable!(immutable Category) instance( return
Rebindable!(immutable Category)(instance_); }
Or should, I do it like that ?
Rebindable!(const Category) instance( return Rebindable!(const
Category)(instance_); }
The immutable and const concepts are really different from C and
C++.
A problem with rebindable is that its current assembly
translation for 'is' test does a byte per byte comparison which
is much less efficient than a direct 64bit comparison of the
struct.
I checked that with dmd. I don't know about gdc and ldc. This is
something that will,be optimized soon I hope.
More information about the Digitalmars-d-learn
mailing list