Title
Uses of non-type parameters that should cause deduction to fail
Status
cd1
Section
13.10.3 [temp.deduct]
Submitter
Jason Shirk

Created on 2002-07-29.00:00:00 last changed 196 months ago

Messages

Date: 2003-10-15.00:00:00

[Voted into WP at October 2003 meeting.]

Date: 2002-10-15.00:00:00

Proposed resolution (October 2002):

Add after the fourth-to-last bullet of 13.10.3 [temp.deduct] paragraph 2:

  • Attempting to give an invalid type to a nontype template parameter. [Example:
      template <class T, T> struct S {};
      template <class T> int f(S<T, T()>*);
      struct X {};
      int i0 = f<X>(0);
    
    ]
Date: 2002-11-08.00:00:00

I understand the rules in 13.10.3 [temp.deduct] paragraph 2 are meant to be an exhaustive list of what can cause type deduction to fail.

Consider:

  template<typename U,U u> struct wrap_t;

  template<typename U> static yes check( wrap_t<U,U(0)>* );

  struct X { X(int); };
  int main() {
    check<X>(0);
  }

I can see 2 reasons this might cause type deduction to fail:

  • Conversion is not a compile time constant.
  • Non-type parameter is a class type.

Neither case is mentioned in 13.10.3 [temp.deduct] paragraph 2, nor do I see a DR mentioning these.

History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2004-04-09 00:00:00adminsetmessages: + msg1026
2003-11-15 00:00:00adminsetstatus: ready -> wp
2003-04-25 00:00:00adminsetstatus: review -> ready
2002-11-08 00:00:00adminsetmessages: + msg744
2002-11-08 00:00:00adminsetstatus: open -> review
2002-07-29 00:00:00admincreate