I'm trying to implement an instantiator function for my Bound
template wrapper but I can't get it to work. I need this in order to convince people at work that we should switch from Ada
to D.
I want this template
/** Bounded Value of Type T. */
struct Bound(T,
T min = T.min,
T max = T.max,
bool Exceptional = true) {
...
}
to be instantiated as
auto x = bound!(0.0, 10.0)(1.0);
That is I want the first template argument T
to be inferred by the values of the template parameters min
and max
. But how do I specify a template parameter with a default value?
Of course I could always do
auto bound(float min, float max, bool Exceptional = true)(float value) {
return Bound!(float, min, max, Exceptional)(value);
}
but how do I make bound
a template?