There´s a typeid operator that relies on RTTI and provides type information at runtime. Providing specialized templates allows compile time decision, and that´s probably what you want.
You can´t specialize member templates and you can´t partially specialize non member function, but you can use a (partially) specialized inserter template.
// generic Edge Inserter
template<typename Container, typename EdgeType>
void operator()( Container& c, const EdgeType& e )
// insert edge into container
c.push_back( e );
// specialized Edge Inserter
void operator()( Container&c, const Arc& a )
// insert arc into container
c.push_back( a );
template<typename T, typename EdgeType>
// Container to hold edges (whatever this is)
void add_edge( const EdgeType& NewEdge )
// use inserter to add edge
Inserter( Edges, NewEdge );
Last edited by GNiewerth; February 12th, 2009 at 04:43 AM.
Boost has a typeof macro. gcc supports it natively and its emulated elsewhere. Its here.
Get Microsoft Visual C++ Express here or CodeBlocks here.
Get STLFilt here to radically improve error messages when using the STL.
Get these two can't live without C++ libraries, BOOST here and Loki here.
Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
Always use [code] code tags [/code] to make code legible and preserve indentation.
Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.