|
Boost Users : |
From: David Abrahams (dave_at_[hidden])
Date: 2006-11-12 18:22:16
David Abrahams <dave_at_[hidden]> writes:
> "Michael Marcin" <mmarcin_at_[hidden]> writes:
>
>> Hello,
>>
>> I have a fixed point math class and I want to enable some optimized operator
>> overloads.
>>
>> for instance:
>>
>> fixed& fixed::operator /= ( const fixed &rhs );
>> fixed& fixed::operator /= ( int n );
>>
>> it seems however to me that what I really want is an overload like:
>>
>> template< typename T >
>> fixed& operator /= ( typename
>> boost::enable_if<boost::is_integral<T>,T>::type n );
>>
>> However I can't seem to get that function considered for overload
>> resolution
>
> Because your type T there is in a nondeduced context.
>
> You need
>
> template < typename T >
> boost::enable_if<boost::is_integral<T>,fixed&> operator/=(T n)
Whoops
template < typename T >
typename boost::enable_if<boost::is_integral<T>,fixed&>::type
operator/=(T n)
Sorry.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
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