Export (0) Print
Expand All
Expand Minimize

Compiler Error C2651

Error Message

'data type' : left of 'operator' must be a class, struct or union

To use a template parameter as if it is a class, specialize the class template with a class instead of an integral type.

The following sample generates C2651:

// C2651.cpp
template<typename T, typename T::PMF pmf>
struct X1 {};

struct Y1 {
   typedef void (Y1::*PMF)();

   void mf() {
   }
};

void f1() {
   X1<int, 0> x11;   // C2651
   X1<Y1, &Y1::mf> x12;   // OK
}

Community Additions

ADD
Show:
© 2014 Microsoft