This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


782. Lambda expressions and argument-dependent lookup

Section: 7.5.5  [expr.prim.lambda]     Status: CD2     Submitter: Mike Miller     Date: 1 March, 2009

[Voted into the WP at the July, 2009 meeting as part of N2927.]

Functions and function objects behave differently with respect to argument-dependent lookup. In particular, the associated namespaces of a function's parameters and return types, but not the namespace in which the function is declared, are associated namespaces of the function; the exact opposite is true of a function object. The Committee should consider rectifying that disparity; however, in the absence of such action, an explicit decision should be made as to whether lambdas are more function-like or object-like with respect to argument-dependent lookup. For example:

    namespace M {
      struct S { };
    }
    namespace N {
      void func(M::S);
      struct {
        void operator()(M::S);
      } fn_obj;
      const auto& lambda = [](M::S){};
    }
    void g() {
      f(N::func);    // assoc NS == M, not N
      f(N::fn_obj);  // assoc NS == N, not M
      f(N::lambda);  // assoc NS == ??
    }

Proposed resolution (July, 2009)

See document PL22.16/09-0117 = WG21 N2927.