You’re coding up a C++/WinRT runtime class, and the compiler spits out an error message:
error C2660: 'MyClass::Thing1': function does not take N arguments
If you’re really unlucky, you’ll get
error C2064: term does not evaluate to a function taking N arguments
where N is probably 0 or 1.
You may have failed to implement all the necessary overloads of a method.
C++/WinRT events are represented by a pair of overloads:
Operation | Signature (simplified) | Example |
---|---|---|
Register | event_token Event(Delegate const& handler); | token = o.Event(handler); |
Unregister | void Event(event_token const& token); | o.Event(token); |
C++/WinRT read/write properties are also represented by a pair of overloads:
Operation | Signature (simplified) | Example |
---|---|---|
Read | T Property(); | auto value = o.Property(); |
Write | void Property(T const& value); | o.Property(value); |
And naturally, if you have overloaded methods, then they are represented by, um, overloaded methods.
Signature (simplified) | Example |
---|---|
void Method(); | o.Method(); |
void Method(int32_t value); | o.Method(2); |
void Method(int32_t value, hstring name); | o.Method(2, L"Bob"); |
If you fail to implement all of the required methods, you will get an error when the C++/WinRT autogenerated code tries to call one of the missing overloads. When there is a mismatch between the call site and the function prototype, the compiler assumes that the prototype is correct and the call site is wrong. Therefore, the error won’t be “You forgot to declare the 1-parameter overload of this method.” It’ll be “The method I found doesn’t take 1 parameter.”
Since this is autogenerated code, I assume some sort of assertion could have been generated to check that the appropriate overload exists, thus giving a more helpful error message?