|
Boost Users : |
From: Bill Buklis (boostuser_at_[hidden])
Date: 2008-05-06 17:35:23
I would like to able to provide two versions of a function where one is
enabled for only POD types and other another if the object provides a usable
member function (mainly used for compatible non POD types). Anything else
should fail to compile. The first part is easy. I can do this with:
template< class T >
typename boost::enable_if< boost::is_pod<T>, void >::type
DoSomething( T& object )
{
...
}
But, I'm not sure how to do the second part. For example:
template< class T >
typename boost::enable_if< has "DoSomething" member, void >::type
DoSomething( T& object )
{
Object.DoSomething();
}
Perhaps it would be easier to check for a defined typedef inside the object?
But, I'm not sure on that either.
Additionally, if possible: If both conditions can be satisfied then the
second version (member function) should be preferred.
Is this possible?
Thanks,
-- Bill --
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net