How do I manually instantiate template functions with -fno-implicit-templates

Alexandre Oliva oliva@dcc.unicamp.br
Tue Jan 6 14:09:00 GMT 1998


Mark Johnstone writes:

> void test(test_box *);  // Just a forward declaration

this forward-declares a non-template function, which is not the same
as a template-function with the same name and argument list:

> template void test<> (test_box *);  // This is the guiding decl

When you call:

>     test(&box1);

the non-template function is preferred over the template version, so
you're invoking a function that has never been defined.  You must fix
the forward declaration; instead of declaring what you intended to be
a specialization, you must declare the template function:

template <class BOX> void test(BOX *the_box);

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



More information about the Gcc mailing list