On Thu, 27 Nov 2003 12:35:34 +0100, Gabriel Schreiber
<sc*******@ient.rwth-aachen.de> wrote:
Hi
this code:
#include <vector>
void f()
{
struct arg{};
std::vector<arg> v;
};
gets the error message:
: template-argument `f()::arg' uses local type `f()::arg'
: template argument 2 is invalid
can anyone explain this?
And: Is it possible in any way to instantiate templates with local
types?
No, the problem is that template arguments must have external linkage,
but local types have no linkage. You can move the struct to an
anonymous namespace to work around the problem without polluting a
namespace with your type.
You might want to read this:
http://std.dkuug.dk/jtc1/sc22/wg21/d...2003/n1427.pdf
Tom
C++ FAQ:
http://www.parashift.com/c++-faq-lite/
C FAQ:
http://www.eskimo.com/~scs/C-faq/top.html