On 8/8/12, Richard Guenther <richard.guent...@gmail.com> wrote:
> On Aug 7, 2012 Lawrence Crowl <cr...@google.com> wrote:
> > On 8/7/12, Richard Guenther <richard.guent...@gmail.com> wrote:
> > > For most parts overloads that take an (unsigned) HOST_WIDE_INT
> > > argument would be nice, as well as the ability to say dbl + 1.
> >
> > Hm.  There seems to be significant opinion that there should
> > not be any implicit conversions.  I am okay with operations as
> > above, but would like to hear the opinions of others.
>
> Well, I'd simply add
>
>   double_int operator+(HOST_WIDE_INT);
>   double_int operator+(unsigned HOST_WIDE_INT);
>
> and be done with it ;)  Yes, a tad bit more inconvenient on the
> implementation side compared to a non-explicit constructor from
> HOST_WIDE_INT or a conversion operator ... but adhering to the
> rule that we do _not_ want such automatic conversions (well, yet,
> for the start).

Ah, we have a different definition of implicit conversion.  In my
mind, the above overloads do an implicit conversion.  The issue
is that the calling code does not make the conversion obvious.
Note the difference in

   a = b + i;
   a = b + double_int(i);

Using overloads as above is generally safer than using an implicit
converting constructor or an implicit conversion operator.  If folks
are really only objecting to the implementation technique, we have
a somewhat different outcome.

-- 
Lawrence Crowl

Reply via email to