D
Dave Miller
How can you pass a string through a template parameter? I am trying
to avoid using the stream objects and need to pass in class specific
information at creation.
Any information would be helpful. Thanks,
dmille
i.e.
template<class T, const char *FMT>
class Foo
{
private :
T _x ;
public :
foo() {}
short scan_it( const char *src )
{
return sscanf( src, FMT, &_x ) ;
}
} ;
typedef Foo<long, "%ld"> LongFoo ;
....
LongFoo tmp ;
tmp.scan_it( "192" ) ;
to avoid using the stream objects and need to pass in class specific
information at creation.
Any information would be helpful. Thanks,
dmille
i.e.
template<class T, const char *FMT>
class Foo
{
private :
T _x ;
public :
foo() {}
short scan_it( const char *src )
{
return sscanf( src, FMT, &_x ) ;
}
} ;
typedef Foo<long, "%ld"> LongFoo ;
....
LongFoo tmp ;
tmp.scan_it( "192" ) ;