Subject: Re: [geometry] Using Boost.Geometry with a legacy class hierarchy
From: Barend Gehrels (barend_at_[hidden])
Date: 2012-02-22 13:28:56
On 22-2-2012 12:53, Mats Taraldsvik wrote:
> Ok, so even though I define the four "versions" of QPoint (QPoint
> const*const, QPoint* const, QPoint const* and QPoint*), Boost.Geometry
> can't properly handle/distinguish between the QPoint* and QPoint const*?
First: you don't have to provide traits for "const" versions, so ending
with const. So the QPoint const* const is redundant.
Second, you indeed *have* to provide traits for "const *" version
because that is a different type.
Boost.Geometry is using boost::remove_const to get the correct traits.
But boost::remove_const<QPoint const*> does not remove the const (which
is correct). boost::remove_const<QPoint const* const> correctly removes
the last const and keeps the first.
Maybe we can change our library by using something more sophisticated
if (is_pointer) add_pointer(remove_const(remove_pointer))
which should remove the need of the const specialization.
We have to discuss that. The const version basically adds something nice
too because it defines only the "get" in the traits, and not the "set".
> I guess the only or best available workaround is to iterate through
> the QPoint*, and return references to QPoint?
I think so.
Though (I add this again) I also got it (wkt streaming) working by
modifying one line in Boost.Geometry, based on the pointer-version (my
> I hope you can solve this. :) If you want to use the code as an
> example of adapting legacy classes/objects in the documentation, I'll
> be happy to write a few accompanying paragraphs. :)
That is welcome!
Geometry list run by mateusz at loskot.net