S
stinos
Hi All!
suppose a class having a function for outputting data somehow,
class X
{
template< class tType >
void Output( const tType& arg )
{
//default ToString handles integers/doubles
myOutput( ToString( arg ) );
}
//String itself can be outputted directly
template<>
void Output< String >( const String& arg )
{
myOutput( arg );
}
void myOutput( const String& s );
};
now I'd like to add functionality in some way, be it through
specialization or overloading or just anything, so that when a
std::vector< tType > is passed in, it does something like
void Output( const vector< tType >& arg )
{
const size_t nItems = arg.size();
for( size_t i = ; 0 i < nItems ; ++i )
Output( arg[ i ] );
}
Any ideas on how to achieve this? Or more general, how to find out
whether a type passed in is a plain type, or a something< type>.
I checked the boost libs a bit, because they seem to rely on template
stuff a lot, but couldn't find an answer immedeately..
Thanks in advance!
suppose a class having a function for outputting data somehow,
class X
{
template< class tType >
void Output( const tType& arg )
{
//default ToString handles integers/doubles
myOutput( ToString( arg ) );
}
//String itself can be outputted directly
template<>
void Output< String >( const String& arg )
{
myOutput( arg );
}
void myOutput( const String& s );
};
now I'd like to add functionality in some way, be it through
specialization or overloading or just anything, so that when a
std::vector< tType > is passed in, it does something like
void Output( const vector< tType >& arg )
{
const size_t nItems = arg.size();
for( size_t i = ; 0 i < nItems ; ++i )
Output( arg[ i ] );
}
Any ideas on how to achieve this? Or more general, how to find out
whether a type passed in is a plain type, or a something< type>.
I checked the boost libs a bit, because they seem to rely on template
stuff a lot, but couldn't find an answer immedeately..
Thanks in advance!