Title
Lambda expressions and argument-dependent lookup
Status
cd2
Section
7.5.5 [expr.prim.lambda]
Submitter
Mike Miller

Created on 2009-03-01.00:00:00 last changed 143 months ago

Messages

Date: 2009-07-15.00:00:00

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

Date: 2009-07-15.00:00:00

Proposed resolution (July, 2009)

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

Date: 2009-03-01.00:00:00

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 == ??
    }
History
Date User Action Args
2010-03-29 00:00:00adminsetstatus: wp -> cd2
2009-11-08 00:00:00adminsetstatus: dr -> wp
2009-08-03 00:00:00adminsetmessages: + msg2252
2009-08-03 00:00:00adminsetmessages: + msg2251
2009-08-03 00:00:00adminsetstatus: open -> dr
2009-03-01 00:00:00admincreate