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

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

Boost.Range sliced range adaptor is adapted to Boost.Geometry


Boost.Range sliced range adaptor creates a slice of a range (usually a linestring)

Model of

The Boost.Range sliced range adaptor takes over the model of the original geometry, which might be:


#include <boost/geometry/geometries/adapted/boost_range/sliced.hpp>

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


Shows how to use a Boost.Geometry linestring, sliced by Boost.Range adaptor

#include <iostream>

#include <boost/assign.hpp>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/adapted/boost_range/sliced.hpp>

int main()
    using namespace boost::assign;

    typedef boost::geometry::model::d2::point_xy<int> xy;
    boost::geometry::model::linestring<xy> line;
    line += xy(0, 0);
    line += xy(1, 1);
    line += xy(2, 2);
    line += xy(3, 3);
    line += xy(4, 4);

        << boost::geometry::dsv(line | boost::adaptors::sliced(1, 3)) << std::endl;

    return 0;


((1, 1), (2, 2))