Previously we were having fun with generic programming. When last we tuned in
I had...
An enum:
enum ORDER {DESCENDING, ASCENDING};
An Interface:
public interface Ranker(T) {
bool submit(T value); // submits a value of type T to be included in
top 'n' values, true if added or already present
bool expire(T value); // removes a previously included value of type
T from top 'n' values, false if non-existant
T extreme(); // returns the value of type T from Ranker
which is the current top value
}
And a Class Template:
class Rank(T, ORDER rankOrder = ORDER.ASCENDING) : Ranker!(T)
>From this and some implementation magic we can create objects that track the
>top (or bottom) 'n' elements submitted to it.
So far, so good.
I'm trying to create an alias that lets me create these objects like this:
auto top32 = MaxRank(int)(32);
Where '32' is the number of top elements to track.
So we create template aliases like this:
template MinRank(T) {
alias Rank!(T, ORDER.DESCENDING) MinRank;
}
template MaxRank(T) {
alias Rank!(T, ORDER.ASCENDING) MaxRank;
}
And that works, but only if I create the MaxRank by including an exclamation
point thusly:
auto top32 = MaxRank!(int)(32);
Well, that kind of defeats one of the purposes of creating a template alias.
With just a little more effort I can just type:
auto top32 = Rank!(int, ORDER.ASCENDING);
Is there any way to get around including the exclamation point?
Thanks,
eris