Boost::Any ported to D

notknown notknown at none.com
Wed Sep 27 05:41:01 PDT 2006


I was just wondering if this is still the case with D, but iirc at least 
some time ago I remember that you should use "is" keyword to test if 
object is null because "==" means opEquals.


> I used workaround with static if:
> 
> Any assign(ValueType)(ValueType value) {
>         static if (is(ValueType == Any)) content = value.content!=null ? 
>                 value.content.clone() : null;
>         else content=new Holder!(ValueType)(value);
>         return this;
> }
> 
> but why below doesn't work?:
> Any assign(ValueType)(ValueType value) {
>         content=new Holder!(ValueType)(value);
>         return this;
> }
> 
> Any assign(ValueType : Any)(ValueType value) {
>         content = value.content!=null ? value.content.clone() : null;
>         return this;
> }
> 
> according to documentation specialization is not permitted when using
> implicit instatiation. But still don't know why...
> 

static if (is(ValueType == Any)) content = value.content !is null ?
         value.content.clone() : null;                     ^----- there


Or then I have old/wrong information.



More information about the Digitalmars-d-announce mailing list