Original Post
Very quick simple question. Is it possible to 'ask' the compiler if a template type has a specific function, and generate different code if it does? Example:
template <typename type>
void SaveObject(const type &obj,fileptr *file)
{
#iftemplatehasfunction< type, void Save(fileptr*) const >
obj.Save( file );
#else
file->write( &obj, sizeof( obj ) );
#endif
} If not, is there another way around this type of situation? I use a templated function for resource management. But recently I realized that I need to allow some resource types to 'compare' themselves to other resources of the same type to see if the resources match completely regarding specifics for that type (IE, a skinmesh might need to compare morph targets). The only alternative would be to go back and force every object that can be loaded as a resource to implement a 'return true' version of this function. Thanks for any information.