|
Geometry : |
Subject: Re: [geometry] Using Boost.Geometry with a legacy class hierarchy
From: Mats Taraldsvik (mats.taraldsvik_at_[hidden])
Date: 2012-03-07 08:17:45
Hi Barend,
I have tried to define a random access iterator, but I am getting a lot
of compiler errors, possibly related to iterator conversion or pointer
conversion, which I don't understand. Could you take a look?
https://gist.github.com/1852693 (most recent version)
Thanks,
Mats
On 02/22/2012 07:28 PM, Barend Gehrels wrote:
> Hi Mats,
>
> 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
> such as
>
> 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
> first answer).
>
>>
>> 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!
>
> Thanks, Barend
>
>
>
> _______________________________________________
> Geometry mailing list
> Geometry_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/geometry
Geometry list run by mateusz at loskot.net