Templates with multiple enums are void

Andrej Mitrovic andrej.mitrovich at test.com
Fri Aug 27 15:33:55 PDT 2010


Yeah, I ran into this as well. And I've posted about it on this NG already.


I have made this bug report some time ago:

http://d.puremagic.com/issues/show_bug.cgi?id=4675



Simen kjaeraas Wrote:

> Don <nospam at nospam.com> wrote:
> 
> > Jonathan M Davis wrote:
> >> 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?
> >
> > You're wrong about that.
> 
> Actually, according to TDPL, that is correct. "A template using the
> eponymous trick may define other names inside, but those are simply
> inaccessible from the outside." (page 281)
> 
> -- 
> Simen



More information about the Digitalmars-d-learn mailing list