Title
Must member function templates be instantiated during overload resolution?
Status
nad
Section
13.9.2 [temp.inst]
Submitter
Daveed Vandevoorde

Created on 2004-11-24.00:00:00 last changed 239 months ago

Messages

Date: 2005-04-15.00:00:00

Rationale (April, 2005):

In order for this question to come up, there would need to be a “gap” between the the normal rules and the rules for template argument deduction failure. The resolution for issue 488 will close the only such gap of which the CWG is aware. The issue can be reopened if other such cases turn up.

Date: 2022-11-20.07:54:16

A related question to that raised in issue 488 is whether member function templates must be instantiated if the compiler can determine that they will not be needed by the function selected by overload resolution. That is explicitly specified for class templates in 13.9.2 [temp.inst] paragraph 5:

If the overload resolution process can determine the correct function to call without instantiating a class template definition, it is unspecified whether that instantiation actually takes place.

Should the same be true for member function templates? In the example from issue 488,

    struct S {
        template <typename T> S(const T&);
    };
    void f(const S&);
    void f(int);
    void g() {
        enum E { e };
        f(e);    // ill-formed?
    }

a compiler could conceivably determine that f(int) would be selected by overload resolution (because it involves only an integral promotion, while the alternative requires a user-defined conversion) without instantiating the declaration of the S constructor. Should the compiler have that freedom?

History
Date User Action Args
2005-05-01 00:00:00adminsetmessages: + msg1200
2005-05-01 00:00:00adminsetstatus: open -> nad
2004-11-24 00:00:00admincreate