Is there a way to see if .init has been set by the user?
simendsjo
simendsjo at gmail.com
Sat Sep 21 07:11:42 PDT 2013
On Saturday, 21 September 2013 at 13:55:00 UTC, Dicebot wrote:
> On Saturday, 21 September 2013 at 13:48:00 UTC, simendsjo wrote:
>> On Saturday, 21 September 2013 at 13:38:44 UTC, Dicebot wrote:
>>> On Saturday, 21 September 2013 at 13:30:19 UTC, simendsjo
>>> wrote:
>>>> I'm though of using if for aggregates, yes. But this doesn't
>>>> handle the case where you set the same value is T.init.
>>>
>>> I don't think those two case are any different from the type
>>> system point of view, manual or default.
>>
>> Need some __traits(hasUserSuppliedInit, T) then :)
>
> I am not sure those differ even at compiler level (other than
> at syntax stage) - why would you need it?
I was thinking of "query by example". If a field has been set, it
should be used in a where clause. But if I cannot see the
difference between int.init and 0 for instance, it is impossible
to get it right.
It's possible to solve this using UDAs of course.
More information about the Digitalmars-d-learn
mailing list