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

PrevUpHomeNext

C++11 Array Container

C++11 array containers are adapted to the Boost.Geometry point concept

Description

A C++11 std::array is (optionally) adapted to the Boost.Geometry point concept. It can therefore be used in all Boost.Geometry algorithms.

A std::array can be the point type used by the models linestring, polygon, segment, box, and ring.

Model of

Point Concept

Header

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

The standard header boost/geometry.hpp does not include this header.

Example

Shows how to use a C++11 std::array using Boost.Geometry's distance, set and assign_values algorithms

#include <iostream>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/adapted/std_array.hpp>

BOOST_GEOMETRY_REGISTER_STD_ARRAY_CS(cs::cartesian)

int main()
{
    std::array<float, 2> a = { {1, 2} };
    std::array<double, 2> b = { {2, 3} };
    std::cout << boost::geometry::distance(a, b) << std::endl;

    boost::geometry::set<0>(a, 1.1f);
    boost::geometry::set<1>(a, 2.2f);
    std::cout << boost::geometry::distance(a, b) << std::endl;

    boost::geometry::assign_values(b, 2.2, 3.3);
    std::cout << boost::geometry::distance(a, b) << std::endl;

    boost::geometry::model::linestring<std::array<double, 2> > line;
    line.push_back(b);

    return 0;
}

Output:

1.41421
1.20416
1.55563

PrevUpHomeNext