$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Paul Moore (gustav_at_[hidden])
Date: 2001-01-21 17:33:27
On 16 Jan 2001, at 21:15, Paul Moore wrote:
> On 15 Jan 2001, at 22:02, Jens Maurer wrote:
> > Jens Maurer wrote:
> > > Ok, now we have a nice technical problem to solve: How to allow
> > > for a rational(long) constructor which works even for rational<long>,
> > > where we have to avoid ambiguities with the copy constructor.
I've been thinking about this some more. The practical reason we
needed a constructor from "anything that can be converted to
IntType" was that r += 2 wouldn't compile because it needed two
user-defined conversions.
OK, let's apply some lateral thinking.
The real issue here is that rational::operator+=(IntType) is an
entirely legitimate operation, and I have so far made it work via the
rational constructor from IntType. If I make it explicit, r+=2 just
requires an int->IntType constructor...
This involves a lot of extra typing, but avoids the template
constructor issues. The typing isn't too bad, as it's just
template <typename IntType>
inline rational<IntType>&
rational<IntType>::operator+= (const IntType& i)
{
return operator+=(rational<IntType>(i));
}
There are just a lot of cases to do...
I think I'll go with this unless anyone has any major objections.
Other points:
I'm going to change the boost/operator.hpp usage to the new base
type chaining syntax. Currently sizeof(rational<int>) is 16 on
MSVC, when it should only be 8.
I'll add in usage of call_traits to determine optimal parameter types.
If anyone has any issues with these changes, please shout now.
Thanks,
Paul Moore.