Allow implicit template properties for templates with more than one member
Jarrett Billingsley
kb3ctd2 at yahoo.com
Sat Dec 23 13:24:04 PST 2006
You can do this:
template Foo()
{
const uint Foo = 5;
}
...
uint x = Foo!();
And it automatically looks up Foo!().Foo because it has one member named the
same as the template.
What I'm suggesting is that the "have one member" part be changed. I've
written and seen a lot of template code that does stuff like this:
template SomethingImplementation(T, U)
{
alias Blah!(T) myBlah;
alias Boo!(U) myBoo;
...
const uint result = someNumber;
}
template Something(T, U)
{
alias SomethingImplementation!(T, U).result Something;
}
That is, an "implementation" template to do all the work, which has several
members, and an "interface" template to make it easier to call the
implementation template. Pretty kludgy.
Would it really break anything if the rule were changed so that it would
always just look for a member of the same name of the template, no matter
how many members the template has?
More information about the Digitalmars-d
mailing list