1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 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. 6 7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library 8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. 9 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) 13 14 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP 15 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP 16 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) 20 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 23 #endif 24 25 #define BOOST_GEOMETRY_ADAPTED_STD_RANGE_TAG_DEFINED 26 27 28 #include <cstddef> 29 30 31 #include <boost/geometry/core/access.hpp> 32 #include <boost/geometry/core/tag.hpp> 33 #include <boost/geometry/core/tags.hpp> 34 35 36 namespace boost { namespace geometry 37 { 38 39 40 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS 41 namespace traits 42 { 43 44 45 template <typename Point> 46 struct tag<std::pair<Point, Point> > 47 { 48 typedef segment_tag type; 49 }; 50 51 template <typename Point> 52 struct point_type<std::pair<Point, Point> > 53 { 54 typedef Point type; 55 }; 56 57 template <typename Point, std::size_t Dimension> 58 struct indexed_access<std::pair<Point, Point>, 0, Dimension> 59 { 60 typedef typename geometry::coordinate_type<Point>::type coordinate_type; 61 getboost::geometry::traits::indexed_access62 static inline coordinate_type get(std::pair<Point, Point> const& s) 63 { 64 return geometry::get<Dimension>(s.first); 65 } 66 setboost::geometry::traits::indexed_access67 static inline void set(std::pair<Point, Point>& s, coordinate_type const& value) 68 { 69 geometry::set<Dimension>(s.first, value); 70 } 71 }; 72 73 74 template <typename Point, std::size_t Dimension> 75 struct indexed_access<std::pair<Point, Point>, 1, Dimension> 76 { 77 typedef typename geometry::coordinate_type<Point>::type coordinate_type; 78 getboost::geometry::traits::indexed_access79 static inline coordinate_type get(std::pair<Point, Point> const& s) 80 { 81 return geometry::get<Dimension>(s.second); 82 } 83 setboost::geometry::traits::indexed_access84 static inline void set(std::pair<Point, Point>& s, coordinate_type const& value) 85 { 86 geometry::set<Dimension>(s.second, value); 87 } 88 }; 89 90 91 } // namespace traits 92 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS 93 94 95 }} // namespace boost::geometry 96 97 98 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP 99