Subject: Re: [boost] [gil] What is the status of the Gil extension numeric?
From: Christian Henning (chhenning_at_[hidden])
Date: 2013-03-14 10:27:07


Hi Kris,

>
> Christian, you mean the io extension, do you? I don't see numeric in trunk.

I have yet to add it. Probably this weekend.

> I also have some comments about point2 from gil/utilities.hpp:
>
> {{{
> template <typename T>
> class point2 {
> public:
> [...]
> //--- these 3 functions don't add anything, do they? why not remove them
> rely on defaults?
> point2(const point2& p) : x(p.x), y(p.y) {}
> ~point2() {}
> point2& operator=(const point2& p) { x=p.x; y=p.y; return
> *this; }

You mean that these functions are usually generated by the compiler?

>
> [...]
> point2& operator/=(double t) { x/=t; y/=t; return
> *this; }
> T x,y;
> [...]
> };
>
> [...]
> template <typename T> GIL_FORCEINLINE
> point2<double> operator/(const point2<T>& p, double t) { return t==0 ?
> point2<double>(0,0):point2<double>(p.x/t,p.y/t); }
> /// \ingroup PointModel
> template <typename T> GIL_FORCEINLINE
> point2<T> operator*(const point2<T>& p, std::ptrdiff_t t) { return
> point2<T>(p.x*t,p.y*t); }
> /// \ingroup PointModel
> template <typename T> GIL_FORCEINLINE
> point2<T> operator*(std::ptrdiff_t t, const point2<T>& p) { return
> point2<T>(p.x*t,p.y*t); }
> }}}
>
> So point2 has miltiplication by ptrdiff_t, and division by double. This was
> very confusing for me - that multiplying point2<double> by 0.5 gave me
> point2(0,0).
>
> But this probably is as it is for a reason, so I'm not sure if my idea for
> fixing this is the right way to go: I'd just add * and / for point2<T> and
> T, and add multiplication by double. I'd be happy to try to implement this
> change with some tests, if you think it's the right way to go ;-)

I don't quite get the reasoning myself. I would just use T instead of
std::ptrdiff_t or double. This way the user has to make sure what he
is passing. Maybe someone else can shed some light?

Regards,
Christian