On Jul 21, 4:01 pm, neelsm...@rediffmail.com wrote:
Quote:
I want to give default value as NULL/0 for non-type template
parameter. I using SunStudio on Linux. I have tried following:
Quote:
#define non_closer ((int(*)(FILE*))0L)
Quote:
template<class T, int F(FILE*) = non_closer>
Quote:
but compiler throws error:
Quote:
error: '0u' is not a valid template argument for type 'int (*)(FILE*)'
because function '#'integer_cst' not supported by
dump_decl#<declaration error>' has not external linkage
Quote:
Any idea how can I get this working?
Wait for C++0x.
The current version of the standard specifically states that
this is illegal. The committee apparently had a change of
heart, however, and the current draft has been changed to
explicitly allow the case.
In the meantime, you'll have to define a dummy function, and
take its address, e.g.:
int non_closer( FILE* ) {}
template< typename T, int (*F)( FILE* ) = &non_closer >
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34