Title
Partial specialization failure and the immediate context
Status
open
Section
13.10.3.1 [temp.deduct.general]
Submitter
Daveed Vandevoorde

Created on 2021-06-15.00:00:00 last changed 1 week ago

Messages

Date: 2021-11-15.00:00:00

Notes from the November, 2021 teleconference:

A similar example can be constructed involving overload resolution instead of partial specialization:

  template<typename T, typename U> struct S {};
  template<typename T> struct S<T, T> {};
  template<typename T, typename U> struct S<T*, U*> {};

  template<class T>
  bool f(T, typename S<T, T>::type = 0);
  bool f(...);

  int x;
  bool b = f(&x);  // hard error with gcc, ok with clang
Date: 2021-06-15.00:00:00

Consider the following example:

  template<typename T, typename U> struct S {};
  template<typename T> struct S<T, T> {};
  template<typename T, typename U> struct S<T*, U*> {};
  template<typename... Ts> using V = void;
  template<typename T, typename U = void> struct X {};
  template<typename T> struct X<T, V<typename S<T, T>::type>>;
  X<int*> xpi;

Determining whether the partial specialization of X matches X<int*> requires determining whether one of the partial specializations of S matches S<int*,int*>. The partial specializations of S are ambiguous for this case. The question is whether that ambiguity should be considered in the “immediate context” of the type (SFINAE) or whether it should result in a hard error. There is implementation divergence on the handling of this example.

History
Date User Action Args
2021-11-15 00:00:00adminsetmessages: + msg6560
2021-06-15 00:00:00admincreate