781f4456c92412be796f3a7dc6d1c1d8bc74cbd1
[platform/upstream/boost.git] / libs / geometry / doc / src / examples / core / ring_type.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // QuickBook Example
3
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9
10 //[ring_type
11 //`Shows how to use the ring_type metafunction, as well as interior_type
12
13 #include <iostream>
14 #include <typeinfo>
15
16 #include <boost/geometry.hpp>
17 #include <boost/geometry/geometries/polygon.hpp>
18 #include <boost/geometry/geometries/point_xy.hpp>
19
20 int main()
21 {
22     typedef boost::geometry::model::d2::point_xy<double> point;
23     typedef boost::geometry::model::polygon<point> polygon;
24
25     typedef boost::geometry::ring_type<polygon>::type ring_type;
26     typedef boost::geometry::interior_type<polygon>::type int_type;
27
28     std::cout << typeid(ring_type).name() << std::endl;
29     std::cout << typeid(int_type).name() << std::endl;
30
31     // So int_type defines a collection of rings,
32     // which is a Boost.Range compatible range
33     // The type of an element of the collection is the very same ring type again.
34     // We show that.
35     typedef boost::range_value<int_type>::type int_ring_type;
36
37     std::cout
38         << std::boolalpha
39         << boost::is_same<ring_type, int_ring_type>::value
40         << std::endl;
41
42     return 0;
43 }
44
45 //]
46
47 //[ring_type_output
48 /*`
49 Output (using gcc):
50 [pre
51           N5boost8geometry5model4ringINS1_2d28point_xyIdNS0_2cs9cartesianEEELb1ELb1ESt6vectorSaEE
52 St6vectorIN5boost8geometry5model4ringINS2_2d28point_xyIdNS1_2cs9cartesianEEELb1ELb1ES_SaEESaIS9_EE
53 true
54 ]
55 */
56 //]