Movatterモバイル変換


[0]ホーム

URL:


Issue 2303 - WG21 CWG Issues
Title
Partial ordering and recursive variadic inheritance
Status
cd5
Section
13.10.3.2 [temp.deduct.call]
Submitter
John Spicer

Created on2016-05-24.00:00:00 last changed62 months ago

Messages

msg6423 (view)
Date: 2018-11-15.00:00:00

Proposed resolution (November, 2018):

Change 13.10.3.2 [temp.deduct.call] bullet 4.3 as follows:

In general, the deduction process attempts to find templateargument values that will make the deduced A identical to A(after the type A is transformed as described above). However,there are three cases that allow a difference:

  • ...

  • IfP is a class andP has theformsimple-template-id, then the transformedAcan be a derived classD of thededucedA. Likewise, ifP is a pointer to aclass of the formsimple-template-id, thetransformedA can be a pointer to a derivedclassD pointed to by thededucedA.However, if there is a classCthat is a (direct or indirect) base class ofD andderived (directly or indirectly) from a classB and thatwould be a valid deducedA, the deducedAcannot beB or pointer toB, respectively.[Example:

  •   template <typename... T> struct X;  template <> struct X<> {};  template <typename T, typename... Ts> struct X<T, Ts...> : X<Ts...> {};  struct D : X<int> {};  template <typename... T>  int f(const X<T...>&);  int x = f(D());  // callsf<int>, notf<>                   //B isX<>,C isX<int>

    end example]

msg6201 (view)
Date: 2018-03-15.00:00:00

Notes from the March, 2018 meeting:

The relevant specification is in 13.10.3.2 [temp.deduct.call] bullet4.3 and paragraph 5, which specifies that if there is more than onepossible deducedA, deduction fails. The consensus was to addwording similar to that of overload resolution preferring“nearer” base classes.

msg5947 (view)
Date: 2019-02-15.00:00:00

[Accepted as a DR at the February, 2019 meeting.]

The status of an example like the following is not clear:

  template <typename... T>              struct A;  template <>                           struct A<> {};  template <typename T, typename... Ts> struct A<T, Ts...> : A<Ts...> {};  struct B : A<int> {};  template <typename... T>  void f(const A<T...>&);  void g() {    f(B{});  }

This seems to be ambiguous in the current wording becauseA<> andA<int> both succeed in deduction.It would be reasonable to prefer the more derived specialization.

History
DateUserActionArgs
2020-12-15 00:00:00adminsetmessages: +msg6423
2020-12-15 00:00:00adminsetstatus: drafting -> cd5
2018-04-11 00:00:00adminsetmessages: +msg6201
2018-04-11 00:00:00adminsetstatus: open -> drafting
2016-05-24 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp