On Thursday, 30 January 2014 at 22:34:52 UTC, Frustrated wrote:
On Thursday, 30 January 2014 at 21:33:09 UTC, Namespace wrote:
I think for your example, the first case works fine using
deduction.

Sure but this is not always possible. ;)

It seems that the problem occurs also with opIndex and so probably with all op* methods. See:
http://forum.dlang.org/thread/bug-1204...@https.d.puremagic.com%2Fissues%2F#post-lcegar:241ld2:241:40digitalmars.com

Yes, because they all are implicit. It looks like you are calling
a template. D could figure this out but I think it will end up
having similar issues as >> has in C++. Is it an a templated op*
on an object or is it template function call?

Explan it please with examples. I'm convinced that D is smarter as C++ with the '>>' problem.
---
class Foo {
    void opCall(size_t count) { }
}

Foo f = new Foo();
f(42); /// no template
----

----
class Foo {
    void opCall(T)(size_t count) { }
}

Foo f = new Foo();
f!int(42); /// template
----
No ambiguity.

As far as I understand you, you mean something like this:
----
import std.stdio;

class Foo {
        void opCall(size_t count) {
                writeln("F()");
        }
}

void f(T)(size_t count) {
        writeln("f()");
}

void main()
{
        Foo f = new Foo();
        f(42);
}
----
which prints correctly "F()"

Reply via email to