recursive template (first attempt)
Don Clugston
dac at nospam.com.au
Thu Apr 20 11:57:25 PDT 2006
akcom wrote:
> Ryan Steen wrote:
>> In article <e26v01$2m8$1 at digitaldaemon.com>, akcom says...
>>
>>
>>> static if ( t.length == 0 )
>>> static if ( t.length & 1 )
>>> main.d(49): expression ((t).length) == 0u does not evaluate to a boolean
>>> main.d(53): expression ((t).length) & 1u does not evaluate to a boolean
>>
>> "It is an error if AssignExpression ... cannot be evaluated at compile time."
>>
>>
> why can't it be computed at compile time if I make "str" static/const?
It's just because array literals are only supported at this time for
strings. (Your code might work in DMD 2.0).
If you change the definitions to
const char [] str = x"01 02 03";
template aphasht( char [] T)
{
const uint aphasht = ...
}
(changing returns to const aphasht).
it would work with
writefln( "aphasht(str) = %X", aphasht!(str ) );
More information about the Digitalmars-d-learn
mailing list