Templates with multiple enums are void
Jonathan M Davis
jmdavisprog at gmail.com
Fri Aug 27 00:31:40 PDT 2010
This prints out void:
import std.stdio;
template isX(T)
{
enum val = true;
enum isX = val;
}
void main()
{
writeln(typeof(isX!(int)).stringof);
}
If you change it to
template isX(T)
{
enum val = true;
enum isX = true;
}
it still prints out void. If you get rid of val, it finally prints bool. However,
as I understood it, you should be able to declare multiple enums within the same
template and get this to work as long as you just have the one with the same
name as the template. Am I wrong about that? Or is this a bug?
It's certainly limiting if you can't declare multiple enums. What I'd like to be
able to do is create multiple enums and then && them together to create isX,
thereby nicely breaking up the condition into more manageable pieces. But it
doesn't appear to work at the moment.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list