How to avoid ctRegex (solved)

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 27 10:47:33 PDT 2016


On Saturday, 27 August 2016 at 17:35:04 UTC, cy wrote:
> On Wednesday, 24 August 2016 at 05:29:57 UTC, ag0aep6g wrote:
>> The plain regex function doesn't have such a requirement. It 
>> also works with a pattern that's generated at run time, e.g. 
>> from user input. But you can use it with a compile time 
>> constant, too. And it works in CTFE then, but it does not 
>> "generate optimized native machine code".
>
> It's not using it with a compile time constant that struck me 
> as weird. It's using it to assign a global variable that struck 
> me as weird.

But actual value of that Regex struct is perfectly known during 
compile time. Thus it is possible and fine to use it as 
initializer. You can use any struct or class as initializer if it 
can be computed during compile-time.


More information about the Digitalmars-d-learn mailing list