Nov 23, 2005
编译通过,运行结果如下:
3.14
hello
New/Changed Features
- Added std.string.soundex.
- Added std.string.entab.
- Added std.string.wrap.
- Added std.string.abbrev.
- Added std.windows.charset (thanks to Stewart Gordon, D/28246).
- Added std.demangle to demangle D names.
- Improved promotion of names inside templates.
- Now allows floating point and string literals as template value arguments.
- To support the previous, the name mangling of template instances has changed. This will necessitate recompilation of any code that uses templates.
- std.utf.UtfError is now deprecated. Use std.utf.UtfException instead.
Bugs Fixed
- Fixed D.bugs/5299
- Fixed D.bugs/5353
- Fixed D.bugs/5360
- Fixed D.bugs/5391
- Fixed D.bugs/5429
- Fixed D.bugs/5464
- Fixed std.string.expandtabs so it handles UTF.
比较感兴趣的是浮点数和字符串常量作为模板值参数,简单测试了一下:
import std.stdio;
template TFloat ( float F)
{
float value = F;
}
template TString ( char [] S)
{
char [] value = S;
}
void main()
{
alias TFloat ! ( 3.14f ) PI;
writefln(PI.value);
writefln(TString ! ( " hello " ).value);
}
template TFloat ( float F)
{
float value = F;
}
template TString ( char [] S)
{
char [] value = S;
}
void main()
{
alias TFloat ! ( 3.14f ) PI;
writefln(PI.value);
writefln(TString ! ( " hello " ).value);
}
编译通过,运行结果如下:
3.14
hello