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


Point Concept


The Point Concept describes the requirements for a point type. All algorithms in Boost.Geometry will check any geometry arguments against the concept requirements.

A point is an entity that has a location in space or on a plane, but has no extent (wiki). The point is the most basic geometry of Boost.Geometry, most other geometries consist of points. (Exceptions are box and segment, which might consist of two points but that is not necessarily the case.)

Concept Definition

The Point Concept is defined as following:


While you can #include boost/geometry/geometries/adapted/std_array.hpp to use std::array<T, D> to model the Point concept, the following code spells it out in detail, as you might use for your own point types:

namespace boost { namespace geometry { namespace traits

template <typename T, std::size_t D> struct tag<std::array<T, D>> { using type = point_tag; };
template <typename T, std::size_t D> struct dimension<std::array<T, D>> : boost::mpl::int_<D> {};
template <typename T, std::size_t D> struct coordinate_type<std::array<T, D>> { using type = T; };
template <typename T, std::size_t D> struct coordinate_system<std::array<T, D>> { using type = boost::geometry::cs::cartesian; };

template <typename T, std::size_t D, std::size_t Index>
struct access<std::array<T, D>, Index> {
    static_assert(Index < D, "Out of range");
    using Point = std::array<T, D>;
    using CoordinateType = typename coordinate_type<Point>::type;
    static inline CoordinateType get(Point const& p) { return p[Index]; }
    static inline void set(Point& p, CoordinateType const& value) { p[Index] = value; }

}}} // namespace boost::geometry::traits

Available Models