|
Boost : |
From: Sid Sacek (ssacek_at_[hidden])
Date: 2007-12-04 14:22:06
>> That's because you cannot instantiate a class template with a string in C++.
Actually you can, but are limited to strings with external linkage. Another problem with this aspect of templates is that not all
compilers support this syntax yet.
-Sid Sacek
#include <stdio.h>
template< const char * name >
class foo
{
const char * val;
public:
foo() : val( name ) { }
const char * value( void ) { return val; }
};
extern const char exname[] = "hello world";
int main( int, char ** )
{
foo< exname > myfoo;
printf( " %s \n", myfoo.value() );
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk