On 7/25/15 5:34 AM, Walter Bright wrote:
On 7/25/2015 2:14 AM, Jonathan M Davis wrote:
I do think that it can make sense to put very similar overloads in a
single
function with static if branches like you're suggesting, but I do
think that
it's a bit of a maintenance issue to do it for completely distinct
overloads -
especially if there are several of them rather than just a couple. But
it's
still possible to combine their template constraints at a higher level
and have
overloaded functions rather than simply using static ifs.
I also sometimes see:
void foo(T)(T t) if (A && B) { ... }
void foo(T)(T t) if (A && !B) { ... }
The user should never have to see the B constraint in the documentation.
This should be handled internally with static if.
There are problems with that but I do agree with the sentiment. -- Andrei