Two questions
Steven Schveighoffer
schveiguy at gmail.com
Wed Jan 2 21:56:03 UTC 2019
On 1/2/19 12:38 PM, IM wrote:
> 2- Yesterday I was experimenting with something and I wrote something
> like the following:
>
> struct MyType {
> ...
> }
>
> void doSomeWork(ref MyType o) {
> ...
> }
>
> auto t = MyType(...);
>
> t.doSomeWork(); // <-- failed to compile.
>
> Why did the above UFCS call fail to compile? I had to do doSomeWork(t)
> instead.
With those ... I have to guess.
There are 2 possibilities.
Possibility 1: there is a method named 'doSomeWork' which takes at least
one parameter. This overrides the UFCS function (member functions always
win over UFCS).
Possibility 2: All this is actually inside a function or unittest.
Nested functions cannot participate in UFCS.
Of course, these are guesses. But given the very scant code above, I'm
not sure I could offer any other suggestions. If neither of those is the
case, I'd need a working example.
-Steve
More information about the Digitalmars-d-learn
mailing list