Koenig lookup in D?

monarch_dodra monarchdodra at gmail.com
Tue Aug 27 01:00:12 PDT 2013


On Tuesday, 27 August 2013 at 07:54:06 UTC, Walter Bright wrote:
> On 8/27/2013 12:45 AM, monarch_dodra wrote:
>> The root reason for this mechanism, is that it allows writing
>> templated functions that can operate on objects from any
>> namespace.
>
> I believe the root reason was so that operator overloads would 
> work when the rvalue was the class type. (In C++ you have to 
> write non-member functions to handle those cases.)
>
> D solves that via other mechanisms, so Koenig lookup is not 
> necessary.

D solves the "operator overloads" mechanism in other ways, yes. 
But it does not provide a mechanism to resolve function calls 
that are defined by the caller, to operate on the passed in type. 
At least, none that I know know of.


More information about the Digitalmars-d mailing list