| 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()
    {
        typedef boost::geometry::model::d2::point_xy<double> point;
        typedef boost::geometry::model::polygon<point> polygon;

        typedef boost::geometry::ring_type<polygon>::type ring_type;
        typedef boost::geometry::interior_type<polygon>::type int_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.
        typedef boost::range_value<int_type>::type int_ring_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