|
Boost Users : |
From: Michael Marcin (mmarcin_at_[hidden])
Date: 2006-11-12 19:34:21
David Abrahams wrote:
> 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.
Thank you. It works and makes sense now because of your explanations.
I've been working for a year now using C++ almost exclusively and there is
still so much left to learn *sigh*.
- Michael Marcin
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