|
Boost Users : |
From: John Maddock (john_maddock_at_[hidden])
Date: 2002-05-03 06:58:44
> I know how to use type traits to enable compile time seperate procedures,
> but not how to use it to define a procedure for some type and not others.
One way (for member functions) is to use inheritance: add an "implementation
layer" that includes the member function or not depending on whether a trait
is true or not:
template <class T, bool b>
struct mybase
{
// details
T operator*();
};
template <class T, true>
struct mybase
{
// details
};
template <class T>
struct mine : public mybase<T, ::boost::is_arithmetic<T>::value>
{
// details
};
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