C array

| Home | Libraries | People | FAQ | More

#### C array

C arrays are adapted to the Boost.Geometry point concept

###### Description

C arrays, such as double[2] or int[3], are (optionally) adapted to the Boost.Geometry point concept. They can therefore be used in many Boost.Geometry algorithms.

Note that a C array cannot be the point type of a linestring or a polygon. The reason for that is that a std::vector does not allow containing C arrays (this is not related to Boost.Geometry). The C array is therefore limited to the point type.

###### Model of

Point Concept

###### Header

`#include <boost/geometry/geometries/adapted/c_array.hpp>`

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

###### Example

Small example showing the combination of an array with a Boost.Geometry algorithm

    #include <iostream>
    #include <boost/geometry.hpp>
    #include <boost/geometry/geometries/adapted/c_array.hpp>

    BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)

    int main()
    {
        int a[3] = {1, 2, 3};
        int b[3] = {2, 3, 4};

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

        return 0;
    }

Output:

    1.73205