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

2024-07-24


997. Argument-dependent lookup and dependent function template parameter types

Section: 6.5.4  [basic.lookup.argdep]     Status: C++11     Submitter: James Widman     Date: 6 November, 2009

[Voted into the WP at the March, 2011 meeting as part of paper N3262.]

6.5.4 [basic.lookup.argdep] paragraph 2 excludes dependent parameter types and return types from consideration in determining the associated classes and namespaces of a function template. Presumably this means that an example like

    namespace N {
      template<class T> struct A { };
      void f(void (*)());
    }

    template <class T>
    void g(T, N::A<T>);

    void g();

    int main() {
      f(g);
    }

is ill-formed because the second parameter of the function template g does not add namespace N to the list of associated namespaces. This was probably unintentional.

See also issue 1015.

Notes from the November, 2010 meeting:

The CWG agreed that the rules should be changed to make this example well-formed.

Proposed resolution (November, 2010) [SUPERSEDED]:

Change 6.5.4 [basic.lookup.argdep] paragraph 2 as follows:

...In addition, if the argument is the name or address of a set of overloaded functions and/or function templates, its associated classes and namespaces are the union of those associated with each of the members of the set, i.e., the classes and namespaces associated with its (non-dependent) parameter types and return type. Additionally, if the aforementioned set of overloaded functions is named with a template-id, its associated classes and namespaces are those of its type template-arguments and its template template-arguments.

This resolution also resolves issue 1015.

[Drafting note: It's not clear that we need the inserted text above, because for the example in issue 1015, the type N::S is already represented in the type of the function address, so there is no need to pull it from template arguments. For cases where template parameters are not represented in the function type, it's not clear that we want ADL to reach further.]