Boost logo

Boost :

From: Moore, Paul (paul.moore_at_[hidden])
Date: 2001-01-22 11:44:51

From: Peter Dimov [mailto:pdimov_at_[hidden]]
> From: "Moore, Paul" <paul.moore_at_[hidden]>
> [...]
> > template <typename IntType> inline rational<IntType>
> > operator- (boost::call_traits<IntType>::param_type i, const
> > rational<IntType>& r)
> > {
> > return rational<IntType>(i) -= r;
> > }
> >
> > The problem is that, for a user-defined integer type MyInt,
> >
> > 4 - rational<MyInt>(9,2)
> >
> > doesn't compile.
> It's MSVC.
> boost::call_traits<IntType>::param_type is non-deducible.
> However, when faced with such a situation, MSVC 'creatively'
> deduces the first template parameter (in this case IntType)
> from the type of the first argument (in this case an int.)
> This is probably a hack in the compiler.

Well, it's partly me. I should have realised that param_type would be
non-deducible. On the other hand, replacing that with a simple IntType still
gives the error. It looks like MSVC is deducing IntType from the first
argument, and then complaining about the second, instead of having another
go by deducing based on the second argument, and then applying conversions
to make the first work.

Isn't this a specific named behaviour (something about "partial ordering")?
I bet there's a standard reference (I'll look when I get home). Looks like
it's something else MSVC gets wrong. Maybe I'll pass it on to David

Thanks for the help,

Boost list run by bdawes at, gregod at, cpdaniel at, john at