Skip to content

CWG2926 [basic.lookup.qual.general] Lookup of dependent qualified names should be done from the point of instantiation #599

Description

@t3nsor

Full name of submitter: Brian Bi

Link to Mattermost thread: https://chat.isocpp.org/general/pl/45iiima6bpgfugwoiztjiyewfw

Issue description: All implementations accept:

template <typename U>
constexpr bool foo = U::b;

template <class T>
struct A {
    A() requires(foo<A>) {}
    static constexpr bool b = true;
};

A<int> a;

Assuming that this is the desired result, lookup for the qualified name U::b should be performed from the point of instantiation of the requires-clause.

Suggested resolution: Edit [basic.lookup.qual.general]/3, adding a bulleted list and including a drive-by fix:

Qualified name lookup in a class, namespace, or enumeration performs a search of the scope associated with it ([class.member.lookup]) except as specified below. Unless otherwise specified, a qualified name undergoes qualified name lookup in its lookup context from the point where it appears unless

  • the lookup context either is dependent and is not the current instantiation ([temp.dep.type]) , in which case the lookup is done from the point of instantiation ([temp.point]) or
  • the lookup context is not a class or class template a type that is neither a class nor enumeration, in which case unqualified lookup is performed.

If nothing is found by qualified lookup for a member-qualified name that is the terminal name ([expr.prim.id.unqual]) of a nested-name-specifier and is not dependent, it undergoes unqualified lookup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions