overloading template functions it not always allowed

szali bszalkai0 at gmail.com
Fri Dec 31 06:09:23 PST 2010


In one of my classes, I created two overloads to opIndexAssign (the
second one was made for better performance, because in most cases
only one index is used):

public final T opIndexAssign(T value, int[] args ...)
public final T opIndexAssign(T value, int i)

These are allowed by the compiler. But these are not:

public T opIndexOpAssign(string op)(T value, int i)
public T opIndexOpAssign(string op)(T value, int[] args ...)

Seems I cannot overload them just because these are template
functions. But I dont see the rationale behind this.

And when I want to make these "final", like this:

public final T opIndexOpAssign(string op)(T value, int i)

the compiler complains because it thinks i want to apply the final
keyword to "string op" (why would I? the keyword is at a completely
different position). That is kind of strange.


More information about the Digitalmars-d-bugs mailing list