1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
14 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP
15 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP
17 // Only possible if the std::pair is not used for iterator/pair
18 // (maybe it is possible to avoid that by detecting in the other file
19 // if an iterator was used in the pair)
21 #ifdef BOOST_GEOMETRY_ADAPTED_STD_RANGE_TAG_DEFINED
22 #error Include only one headerfile to register tag for adapted std:: containers or iterator pair
25 #define BOOST_GEOMETRY_ADAPTED_STD_RANGE_TAG_DEFINED
31 #include <boost/geometry/core/access.hpp>
32 #include <boost/geometry/core/tag.hpp>
33 #include <boost/geometry/core/tags.hpp>
36 namespace boost { namespace geometry
40 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
45 template <typename Point>
46 struct tag<std::pair<Point, Point> >
48 typedef segment_tag type;
51 template <typename Point>
52 struct point_type<std::pair<Point, Point> >
57 template <typename Point, std::size_t Dimension>
58 struct indexed_access<std::pair<Point, Point>, 0, Dimension>
60 typedef typename geometry::coordinate_type<Point>::type coordinate_type;
62 static inline coordinate_type get(std::pair<Point, Point> const& s)
64 return geometry::get<Dimension>(s.first);
67 static inline void set(std::pair<Point, Point>& s, coordinate_type const& value)
69 geometry::set<Dimension>(s.first, value);
74 template <typename Point, std::size_t Dimension>
75 struct indexed_access<std::pair<Point, Point>, 1, Dimension>
77 typedef typename geometry::coordinate_type<Point>::type coordinate_type;
79 static inline coordinate_type get(std::pair<Point, Point> const& s)
81 return geometry::get<Dimension>(s.second);
84 static inline void set(std::pair<Point, Point>& s, coordinate_type const& value)
86 geometry::set<Dimension>(s.second, value);
92 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
95 }} // namespace boost::geometry
98 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP