Unable to instantiate template with same name as function

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 3 01:02:47 PST 2016



Dne 3.3.2016 v 09:58 Shriramana Sharma via Digitalmars-d-learn napsal(a):
> Hello people and thanks for your replies.
>
> Jonathan M Davis via Digitalmars-d-learn wrote:
>
>> You can't overload a function and an eponymous template like that. They
>> need to have distinct names.
> Why is it not possible for the overload to happen? After all, the compiler
> should be able to identify which to use by seeing whether it is followed by
> ! or (), no?
>
>>> Now, that being said, I don't understand why
>> you'd need to do anything with a template for CTFE in this case. Just
>> write the function and then call it in a context that requires a
>> compile-time result, and it should work. e.g.
> OK but say I have a function which returns an array. If I use enum to CTFE
> its result, then it is repeatedly included explicitly in all places it is
> used, thereby using more memory.
you can still use immutable instead of enum



More information about the Digitalmars-d-learn mailing list