Uri class and parser

jerro a at a.com
Thu Nov 8 07:32:56 PST 2012


> Something entirely else is the CTFE compatibility of URI. At 
> first I though that because a new instance of URI can be 
> created as a const, it would be evaluated on compile time.
> This is part of how I test CTFE at the moment:
>
> const URI uri36 = URI.parse("http://dlang.org/");
> assert(uri36.scheme == "http");
>
> I tried changing 'const' to 'static' but that resulted in an 
> error.
> (_adSort cannot be interpreted at compile time, because it has 
> no available source code)
>
> Now I'm not sure anymore how to test if my code meets the CTFE 
> requirements.

To force something to be evaluated at compile time, you can 
assign it to an enum, like this:

enum uri = URI.parse("http://dlang.org/");



More information about the Digitalmars-d mailing list