Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

model::multi_point

multi_point, a collection of points

Model of

MultiPoint Concept

Synopsis

template<typename Point, template< typename, typename > class Container, template< typename > class Allocator>
class model::multi_point
      : public std::vector< Point, std::allocator< Point > >
{
  // ...
};

Template parameter(s)

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

Constructor(s)

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:

Header

Either

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

Or

#include <boost/geometry/geometries/multi_point.hpp>

Examples

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; 1
    mpoint_t mpt2{{{0.0, 0.0}, {1.0, 1.0}, {2.0, 2.0}}}; 2

    bg::append(mpt1, point_t(0.0, 0.0)); 3
    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;
}

1

Default-construct a multi_point.

2

Construct a multi_point containing three points, using C++11 unified initialization syntax.

3

Append point to the multi_point.

Output:

3

PrevUpHomeNext