Compiler Error C3408
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C3408.
attribute': attribute is not allowed on template definitions
Attributes cannot be applied to template definitions.
The following sample generates C3408.
// C3408.cpp
// compile with: /c
template <class T> struct PTS {
enum {
IsPointer = 0,
IsPointerToDataMember = 0
};
};
template <class T>
[coclass] // C3408
struct PTS<T*> {
enum {
IsPointer = 1,
IsPointerToDataMember = 0
};
};
template
<class T, class U>
struct PTS<T U::*> {
enum {
IsPointer = 1,
IsPointerToDataMember = 1
};
};
struct S{};
extern "C" int printf(const char*,...);
int main() {
S s, *pS;
int S::*ptm;
printf("PTS<S>::IsPointer == %d PTS<S>::IsPointerToDataMember == %d\n", PTS<S>::IsPointer, PTS<S>:: IsPointerToDataMember);
printf("PTS<S*>::IsPointer == %d PTS<S*>::IsPointerToDataMember == %d\n", PTS<S*>::IsPointer, PTS<S*>:: IsPointerToDataMember);
printf("PTS<int S::*>::IsPointer == %d PTS<int S::*>::IsPointerToDataMember == %d\n", PTS<int S::*>::IsPointer, PTS<int S::*>:: IsPointerToDataMember);
}
Show: