detail::relate::less moved to separate file

This commit is contained in:
Adam Wulkiewicz
2014-02-27 02:17:08 +01:00
parent 9ed47574e1
commit 9ad7ec98a8
2 changed files with 70 additions and 44 deletions

View File

@@ -0,0 +1,69 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2014, Oracle and/or its affiliates.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_LESS_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_LESS_HPP
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace relate {
// TODO: should this be integrated with geometry::less?
template <typename Point1,
typename Point2,
std::size_t I = 0,
std::size_t D = geometry::dimension<Point1>::value>
struct less_dispatch
{
static inline bool apply(Point1 const& l, Point2 const& r)
{
typename geometry::coordinate_type<Point1>::type
cl = geometry::get<I>(l);
typename geometry::coordinate_type<Point2>::type
cr = geometry::get<I>(r);
if ( geometry::math::equals(cl, cr) )
{
return less_dispatch<Point1, Point2, I + 1, D>::apply(l, r);
}
else
{
return cl < cr;
}
}
};
template <typename Point1, typename Point2, std::size_t D>
struct less_dispatch<Point1, Point2, D, D>
{
static inline bool apply(Point1 const&, Point2 const&)
{
return false;
}
};
struct less
{
template <typename Point1, typename Point2>
inline bool operator()(Point1 const& point1, Point2 const& point2)
{
return less_dispatch<Point1, Point2>::apply(point1, point2);
}
};
}} // namespace detail::relate
#endif // DOXYGEN_NO_DETAIL
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_LESS_HPP

View File

@@ -16,6 +16,7 @@
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
#include <boost/geometry/algorithms/detail/within/point_in_geometry.hpp>
#include <boost/geometry/algorithms/detail/relate/less.hpp>
namespace boost { namespace geometry
{
@@ -123,50 +124,6 @@ struct multipoint_point
}
};
// TODO: should this be integrated with geometry::less?
template <typename Point1,
typename Point2,
std::size_t I = 0,
std::size_t D = geometry::dimension<Point1>::value>
struct less_dispatch
{
static inline bool apply(Point1 const& l, Point2 const& r)
{
typename geometry::coordinate_type<Point1>::type
cl = geometry::get<I>(l);
typename geometry::coordinate_type<Point2>::type
cr = geometry::get<I>(r);
if ( geometry::math::equals(cl, cr) )
{
return less_dispatch<Point1, Point2, I + 1, D>::apply(l, r);
}
else
{
return cl < cr;
}
}
};
template <typename Point1, typename Point2, std::size_t D>
struct less_dispatch<Point1, Point2, D, D>
{
static inline bool apply(Point1 const&, Point2 const&)
{
return false;
}
};
struct less
{
template <typename Point1, typename Point2>
inline bool operator()(Point1 const& point1, Point2 const& point2)
{
return less_dispatch<Point1, Point2>::apply(point1, point2);
}
};
template <typename MultiPoint1, typename MultiPoint2>
struct multipoint_multipoint
{