August 27, 2010
On Fri, Aug 27, 2010 at 09:31, Jonathan M Davis <jmdavisprog@gmail.com>wrote:

> 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?
>
>
I afraid you're wrong. Or, rather, the eponymous template trick (ETT) is
activated only for one-member templates.
You can declare multiple enums, but not use the ETT at the same time.
There was once some project to define 'private' enums, that wouldn't
interfere with ETT, but it's not implemented now.



> 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.
>

To do that, use a helper template:

template isX(T)
{
    alias isXImpl!(T).result isX; // one eponymous member
}

template isXImpl(T) // no eponymous member, all are accesible
{
    enum foo = isIntegral!T;
    enum bar = isFloatingPoint!T;
    enum baz = isArray!T;
    enum result = foo && bar && !baz; // or alias Tuple!(foo,bar,baz)
result; or whatever
}

It's like rocket science: do a two-stage launch: :)

Philippe