| Home | Libraries | People | FAQ | More

#### ring_type

Metafunction defining type as the ring_type of the specified geometry type.

###### Description

A polygon contains one exterior ring and zero or more interior rings (holes). This metafunction retrieves the type of the rings. Exterior ring and each of the interior rings all have the same ring_type.

###### Synopsis

    template<typename Geometry>
    struct ring_type
    {
      // ...
    };

###### Template parameter(s)

Parameter | Description
--- | ---
typename Geometry | A type fullfilling the Ring, Polygon or MultiPolygon concept.

###### Header

Either

`#include <boost/geometry.hpp>`

Or

`#include <boost/geometry/core/ring_type.hpp>`

###### Complexity

Compile time

###### Example

Shows how to use the ring_type metafunction, as well as interior_type

    #include <iostream>
    #include <typeinfo>

    #include <boost/geometry.hpp>
    #include <boost/geometry/geometries/polygon.hpp>
    #include <boost/geometry/geometries/point_xy.hpp>

    int main()
    {
        using point = boost::geometry::model::d2::point_xy<double>;
        using polygon = boost::geometry::model::polygon<point>;

        using ring_type = boost::geometry::ring_type<polygon>::type;
        using int_type = boost::geometry::interior_type<polygon>::type;

        std::cout << typeid(ring_type).name() << std::endl;
        std::cout << typeid(int_type).name() << std::endl;

        // So int_type defines a collection of rings,
        // which is a Boost.Range compatible range
        // The type of an element of the collection is the very same ring type again.
        // We show that.
        using int_ring_type = boost::range_value<int_type>::type;

        std::cout
            << std::boolalpha
            << boost::is_same<ring_type, int_ring_type>::value
            << std::endl;

        return 0;
    }

Output (using gcc):

    N5boost8geometry5model4ringINS1_2d28point_xyIdNS0_2cs9cartesianEEELb1ELb1ESt6vectorSaEE
    St6vectorIN5boost8geometry5model4ringINS2_2d28point_xyIdNS1_2cs9cartesianEEELb1ELb1ES_SaEESaIS9_EE
    true