...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Macro to register a templated ring.
The macro BOOST_GEOMETRY_REGISTER_RING_TEMPLATED registers a templated ring such that it is recognized by Boost.Geometry and that Boost.Geometry functionality can used with the specified type. The type must have one template parameter, which should be a point type, and should not be specified. Boost.Geometry takes care of inserting the template parameter. Hence all types of this templated ring are registered, regardless of their point type.
#define BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(Ring)
Name |
Description |
---|---|
Ring |
ring (without template parameters) type to be registered |
#include <boost/geometry/geometries/register/ring.hpp>
Show the use of the macro BOOST_GEOMETRY_REGISTER_RING_TEMPLATED
#include <iostream> #include <deque> #include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/register/ring.hpp> // Adapt any deque to Boost.Geometry Ring Concept BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::deque) int main() { std::deque<boost::geometry::model::d2::point_xy<double> > ring(3); boost::geometry::assign_values(ring[0], 0, 0); boost::geometry::assign_values(ring[2], 4, 1); boost::geometry::assign_values(ring[1], 1, 4); // Boost.Geometry algorithms work on any deque now boost::geometry::correct(ring); std::cout << "Area: " << boost::geometry::area(ring) << std::endl; std::cout << "Contents: " << boost::geometry::wkt(ring) << std::endl; return 0; }
Output:
Area: 7.5 Line: ((0, 0), (1, 4), (4, 1), (0, 0))