I know that in C++ we can do this:
class A {} a;
This makes an object of type A named a. It’s equivalent to:
A a;
I was wondering how I would do this with templates. For example:
template <typename T> struct N {} <int> n;
This doesn’t compile, but you get the idea. How would I specify the template arguments to an object created inline with its class definition? Is this even possible?
The stuff after the closing
}is called aninit-declarator-listaccording to the standard.14.3 explicitly forbids them to be used in template class declarations: