I have such code which works well:
#include
#include
char x[11]= \"ABCDEFGHIJ\";
char y[11];
struct F {
char operator ()
In C++-98/03 the second code is not valid, since F is a local type; in facts, at §14.3.1.2 it's stated that
A local type, a type with no linkage, an unnamed type or a type compounded from any of these types shall not be used as a template-argument for a template type-parameter.
[Example:
template class X { /* ... */ };
void f()
{
struct S { /* ... */ };
X x3; // error: local type used as template-argument
X x4; // error: pointer to local type used as template-argument
}
—end example] [Note: a template type argument may be an incomplete type (3.9). ]
In C++-0x this limitation is removed; in the same section, the new standard draft (N3126) explicitly shows this in the example:
[ Example:
template class X { };
template void f(T t) { }
struct { } unnamed_obj;
void f() {
struct A { };
enum { e1 };
typedef struct { } B;
B b;
X x1; // OK
X x2; // OK
X x3; // OK
f(e1); // OK
f(unnamed_obj); // OK
f(b); // OK
}
— end example ] [ Note: a template type argument may be an incomplete type (3.9). — end note ]