In C++, there is this ADL thing (argument dependent lookup).
What it does is, when searching for overloads, in addition to looking
in the local namespace, it also looks in the namespace of the function
arguments.

D doesn't seem to have this, and that is proving to be quite problematic.
What's the work around?

C++ example:

namespace bob {
  struct S {};
  void f(S s);
}

namespace joe {
  struct T {};
  void f(T t);

  void test()
  {
    T t;
    f(t); // obviously works, T is in the local namespace

    bob::S s;
    f(s); // local namespace can't see `void f(S)`, but given the
argument 's', which is typed bob::S, it will search the bob::
namespace for overloads of f(), so this code compiles successfully.
  }
}


I have the same configuration across 2 modules in D.
In one module, I receive the foreign modules type via template arg,
but I haven't imported that type's module, so when I try to call the
function it can't find the overload, because it's not imported, and it
doesn't search the argument type's module (ie, namespace) for
overloads.
  • ADL Manu via Digitalmars-d
    • Re: ADL David Nadlinger via Digitalmars-d
    • Re: ADL Dicebot via Digitalmars-d
    • Re: ADL Steven Schveighoffer via Digitalmars-d
    • Re: ADL Cauterite via Digitalmars-d
    • Re: ADL Walter Bright via Digitalmars-d
      • Re: ADL Manu via Digitalmars-d
      • Re: ADL Walter Bright via Digitalmars-d
        • Re: ADL Stefan Koch via Digitalmars-d
          • Re: ADL Walter Bright via Digitalmars-d

Reply via email to