Can templated functions be used in interfaces?
Maxim Fomin
maxim at maxim-fomin.ru
Thu Jul 11 05:24:17 PDT 2013
On Thursday, 11 July 2013 at 12:03:10 UTC, Jakob Ovrum wrote:
> However, in my opinion, it's a bug that you're allowed to
> declare a function template (when using the shortcut syntax)
> without defining it, whether in an interface or not. This is a
> rather natural bug though, due to the nature of function
> templates:
>
> void a()();
>
> is equivalent of:
>
> template a() { void a(); }
>
> Perhaps it makes sense to allow the declaration without
> definition when the template and function are explicitly
> separated (can anyone think of a case where this is useful?
> Maybe mixin-related?), but when using the former syntax - the
> function template syntax - I don't think it makes any sense.
>
It is possible in current implementation to split template
declaration and definition in different modules but in such case
list of potential template arguments is limited. Disabling this
option in general would disable D ability to hide template
implementation (like libraries and external functions). But in
this particular case I agree that this should be an error like in
situation with static functions.
More information about the Digitalmars-d-learn
mailing list