Boost logo

Boost :

Subject: [boost] [Polygon] trait register on derived class
From: Lechuan Xue (lcxue_at_[hidden])
Date: 2015-08-21 18:04:17


Hi,

Currently, if I have one custom geometry and a few further derived custom geometries, I need to do trait register on all of them. Like:

class derived_point1 : public base_point {};
class derived_point2 : public base_point1 {};

namespace boost { namespace polygon {
    struct geometry_concept<base_point> { typedef point_concept type; };
    struct geometry_concept<derived_point1> { typedef point_concept type; };
    struct geometry_concept<derived_point2> { typedef point_concept type; };
}

What I want is to register all custom geometries in one step. Like:

    template<typename T>
    struct geometry_concept<T, typename std::enable_if<std::is_base_of<base_point, T>()>::type> {
        typedef point_concept type;
    };

To do that, I need to add a dummy template type to all the trait classes to enable SFINAE. Attached is the patch (based on boost 1.57.0_1). Is this something we can consider?

Thanks,
Leo Xue



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk