Re: [Boost-users] Template specialization for Boost.Polygon

On 8/26/19 5:39 PM, Phil Endecott via Boost-users wrote:
Can anyone suggest how I can write my specialisations so that they are unambiguous?
By adding another level of indirection. Create your own trait template. Let both the generalization and your specialization redirect to polygon_traits. Something like this (warning untested code ahead) template <typename T, typename Enable = void> struct my_polygon_traits : public polygon_traits<T, Enable> { }; template <std::size_t N> struct my_polygon_traits<std::array<Point, N>> : public polygon_traits<std::array<Point, N>> { };

Hi Bjorn, Bjorn Reese wrote:
Can anyone suggest how I can write my specialisations so that they are unambiguous?
By adding another level of indirection. Create your own trait template. Let both the generalization and your specialization redirect to polygon_traits.
Something like this (warning untested code ahead)
template <typename T, typename Enable = void> struct my_polygon_traits : public polygon_traits<T, Enable> { };
template <std::size_t N> struct my_polygon_traits<std::array<Point, N>> : public polygon_traits<std::array<Point, N>> { };
Forgive me if I have misunderstood, but how can that cause Boost.Polygon to see my specialisation when it looks up polygon_traits<std::array<Point,3>> ? Regards, Phil.

"Phil Endecott" <spam_from_boost_users@chezphil.org> writes:
Forgive me if I have misunderstood, but how can that cause Boost.Polygon to see my specialisation when it looks up polygon_traits<std::array<Point,3>> ?
I had a similar problem. As it turns out, Boost.Polygon already uses a level of indirection internally. You can specialize boost_polygon_traits_general (instead of boost_polygon_traits). This is undocumented, but it was the only way I found to get it working. I would argue this is a bug, or at least a deficiency. Not sure if the right fix is to change the documentation or the implementation. - Pat

Patrick J. LoPresti wrote:
"Phil Endecott" <spam_from_boost_users@chezphil.org> writes:
Forgive me if I have misunderstood, but how can that cause Boost.Polygon to see my specialisation when it looks up polygon_traits<std::array<Point,3>> ?
I had a similar problem.
As it turns out, Boost.Polygon already uses a level of indirection internally. You can specialize boost_polygon_traits_general (instead of boost_polygon_traits).
THANKS! Yes, that works. It's a hack but I've done worse...
This is undocumented, but it was the only way I found to get it working.
I would argue this is a bug, or at least a deficiency. Not sure if the right fix is to change the documentation or the implementation.
It's clearly a misfeature. Regarding fixing it, I have the impression that Boost.Polygon is essentially abandoned. Are you actively using it? Anyone else out there? Regards, Phil.

On Wed, Aug 28, 2019 at 5:19 PM Phil Endecott wrote:
It's clearly a misfeature. Regarding fixing it, I have the impression that Boost.Polygon is essentially abandoned. Are you actively using it? Anyone else out there?
It has a semi active maintainer who is also a co-author (Andrii Sydorchuk). It does have active users; some submit pull requests too. Glen

On 8/27/19 2:39 PM, Phil Endecott via Boost-users wrote:
Forgive me if I have misunderstood, but how can that cause Boost.Polygon to see my specialisation when it looks up polygon_traits<std::array<Point,3>> ?
Sorry, I did not look into your particular details, but simply described a general way of avoiding ambiguities.
participants (4)
-
Bjorn Reese
-
Glen Fernandes
-
Patrick J. LoPresti
-
Phil Endecott