better assertions and __FILE__ (char[] vs. string)

Bruce Adams ifyoudontknowmebynow at searchdaweb.com
Thu Aug 16 17:28:49 PDT 2007


Frank Benoit Wrote:

> Bruce Adams schrieb:
> > How do I get "foo" to be implicitly interpreted as char[] rather than
> > char[3]. 
> 
> "foo"[]

Thanks. Where is that piece of syntactic sugar documented?

There's still a problem though. The following line:

assertEqual("foo"[],"bar2"[],cast(char[])(__FILE__),__LINE__);
  
fails to compile with:

UnitTest.d(49): template UnitTest.assertEqual(Type) cannot deduce template fun
ion from argument types (invariant(char)[],invariant(char)[],char[],long)

but the explicit instantiation below works.

assertEqual!(invariant(char[]))("foo"[],"bar2"[],cast(char[])(__FILE__),__LINE__);

What's going on?

Regards,

Bruce.



More information about the Digitalmars-d-learn mailing list