...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
multi_point, a collection of points
template<typename Point, template< typename, typename > class Container, template< typename > class Allocator> class model::multi_point : public std::vector< Point, std::allocator< Point > > { // ... };
Parameter |
Default |
Description |
---|---|---|
typename Point |
Any type fulfilling a Point Concept |
|
template< typename, typename > class Container |
std::vector |
container type, for example std::vector, std::deque |
template< typename > class Allocator |
std::allocator |
container-allocator-type |
Function |
Description |
Parameters |
---|---|---|
multi_point()
|
Default constructor, creating an empty multi_point. |
|
template<typename Iterator> multi_point(Iterator begin, Iterator end)
|
Constructor with begin and end, filling the multi_point. |
Iterator: begin: Iterator: end: |
multi_point(std::initializer_list< Point > l)
|
Constructor taking std::initializer_list, filling the multi_point. |
std::initializer_list< Point >: l: |
Either
#include <boost/geometry/geometries/geometries.hpp>
Or
#include <boost/geometry/geometries/multi_point.hpp>
Declaration and use of the Boost.Geometry model::multi_point, modelling the MultiPoint Concept
#include <iostream> #include <boost/geometry.hpp> #include <boost/geometry/geometries/geometries.hpp> namespace bg = boost::geometry; int main() { typedef bg::model::point<double, 2, bg::cs::cartesian> point_t; typedef bg::model::multi_point<point_t> mpoint_t; mpoint_t mpt1; mpoint_t mpt2{{{0.0, 0.0}, {1.0, 1.0}, {2.0, 2.0}}}; bg::append(mpt1, point_t(0.0, 0.0)); bg::append(mpt1, point_t(1.0, 1.0)); bg::append(mpt1, point_t(2.0, 2.0)); std::size_t count = bg::num_points(mpt1); std::cout << count << std::endl; return 0; }
Default-construct a multi_point. |
|
Construct a multi_point containing three points, using C++11 unified initialization syntax. |
|
Append point to the multi_point. |
Output:
3