I have a template that I would like to conditionally compile depending on the type of the argument. I only care about differentiating between \"Plain Old Data\" (POD), i.e., in
You can't solve this with the preprocessor, since it doesn't know about C++. (It's a dumb text replacement tool.) Use templates to do this.
Assuming IsPod returns something alike Boolean/Boolean:
template
class foo
{
void do_something(T obj, Boolean /*is_pod*/)
{
// do something for simple types
}
void do_something(T obj, Boolean /*is_pod*/)
{
// do something for classes/structs
}
void bar(T obj)
{
do_something(obj, IsPod::result());
}
}