Thread overview
Cannot distinguish between template function wtih 0 args and 1 arg
Aug 08, 2016
Engine Machine
Aug 08, 2016
Cauterite
Aug 08, 2016
ag0aep6g
August 08, 2016
This really makes no sense

Error: template Mem cannot deduce function from argument types !(cast(eException)1280L, "main.d", 38u, "main.WinMain")(int), candidates are:
Mem(T, B = eX, string file = __FILE__, uint line = __LINE__, string func = __FUNCTION__)(size_t bytes)
Mem(T, B = eX, string file = __FILE__, uint line = __LINE__, string func = __FUNCTION__)()

Shouldn't these template functions be completely distinguished?

I tried to calling it with and without a value but same error. It is the only error.

This only occurs when I call it with the non-default template values:

I call it simply like Mem!(T, B, file, line, func)(34).

It seems if the template parameters match, that the compiler doesn't test the arguments.

Mem!T(34) works fine.




August 08, 2016
On Monday, 8 August 2016 at 02:36:24 UTC, Engine Machine wrote:
> Error: template Mem cannot deduce function from argument types !(cast(eException)1280L, "main.d", 38u, "main.WinMain")(int), candidates are:
> Mem(T, B = eX, string file = __FILE__, uint line = __LINE__, string func = __FUNCTION__)(size_t bytes)
> Mem(T, B = eX, string file = __FILE__, uint line = __LINE__, string func = __FUNCTION__)()

From this error message it looks like the `B = eX` parameter is not getting matched up against the value `cast(eException)1280L` as you are hoping for. Probably because `1280L` is a value and it's expecting a type.
Try replacing it with something like `alias B = eX` or `enum B = eX`.
August 08, 2016
On 08/08/2016 04:36 AM, Engine Machine wrote:
> This really makes no sense
>
> Error: template Mem cannot deduce function from argument types
> !(cast(eException)1280L, "main.d", 38u, "main.WinMain")(int), candidates
> are:
> Mem(T, B = eX, string file = __FILE__, uint line = __LINE__, string func
> = __FUNCTION__)(size_t bytes)
> Mem(T, B = eX, string file = __FILE__, uint line = __LINE__, string func
> = __FUNCTION__)()

Going backwards:

func is "main.Winmain" - ok.
line is 38u - ok.
file is "main.d" - ok.
B is cast(eException)1280L - B seems to be a type parameter, can't be a value.
T is missing.

The compiler goes forwards, not backwards, of course, so everything is mismatched.

[...]
> This only occurs when I call it with the non-default template values:
>
> I call it simply like Mem!(T, B, file, line, func)(34).

That doesn't look like the instantiation that causes the error. You've got five template arguments here, but in the error there are only four.

Can you post more complete code? Something doesn't add up here.