Checking for possibility of implicit conversions

Nick Sabalausky a at a.a
Wed Mar 14 11:44:35 PDT 2012


"H. S. Teoh" <hsteoh at quickfur.ath.cx> wrote in message 
news:mailman.662.1331746435.4860.digitalmars-d-learn at puremagic.com...
> On Wed, Mar 14, 2012 at 06:08:24PM +0100, Adam D. Ruppe wrote:
>> if(is(T : S))
>>
>> http://dlang.org/expression.html#IsExpression
>>
>> this is form #2.
>
> Ahh, thanks. I keep forgetting what the various forms of is() do... sigh.
>
> Another question: is wstring assignable to dstring, or string to wstring
> or dstring? I'm finding that is(wstring:dstring) returns false.
>

None of those three string types are implicitly convertable to each other.

What might make that a little confusing, though, is that string literals 
which are not suffixed with c/w/d are *not* necessarily string, but rather 
can acually *be* (ie, not "implicitly convertable to", but they actually 
*are*) either string/wstring/dstring depending on context. If it can't be 
inferred from context, *then* string is just simply assumed.




More information about the Digitalmars-d-learn mailing list