I want to define operator * for a point type P.
template <class T>
class TPoint<T>
{
...
template <class U>
TPoint<U> operator *(U t) const;
...
};
template <class T>
template <class U>
TPoint<U> TPoint<T>::operator *(U t) const
{ return TPoint<U>((U)x()/t, (U)y()/t); }
but I only want to define this for types for which
boost::is_arithmetic<U> is true.
This is because
I also want to define operator * for an affine transformation
template
inline Geomt::TPoint<AT> operator *
(const Geomt::TPoint<PT>& pt, const AffHen<AT>& sAH)
{
Geomt::TPoint<AT> pout;
sAH.Pt(pt.x, pt.y, pout.x, pout.y);
return pout;
}
and this sometimes conflicts with the first definition.
At the point of the first definition, type AffHen is unknown,
so I can't branch there then using type traits. What I want to do
is leave all argument types apart from arithmentic types undefined,
to be available for later use.
Is there a well known way to do this apart from making the
affine transform the first argument?
I wonder if boost type traits can help here.
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.
Craig Hicks