/usr/include/boost/geometry/index
Edit: /usr/include/boost/geometry/index/equal_to.hpp (10577B)
// Boost.Geometry Index
//
// Copyright (c) 2011-2016 Adam Wulkiewicz, Lodz, Poland.
//
// This file was modified by Oracle on 2019.
// Modifications copyright (c) 2019 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
//
// 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)
#ifndef BOOST_GEOMETRY_INDEX_EQUAL_TO_HPP
#define BOOST_GEOMETRY_INDEX_EQUAL_TO_HPP
#include
#include
namespace boost { namespace geometry { namespace index { namespace detail
{
template ::type>
struct equals
{
template
inline static bool apply(Geometry const& g1, Geometry const& g2, Strategy const&)
{
return geometry::equals(g1, g2);
}
};
template
struct equals
{
inline static bool apply(Geometry const& g1, Geometry const& g2, default_strategy const&)
{
return geometry::equals(g1, g2);
}
template
inline static bool apply(Geometry const& g1, Geometry const& g2, Strategy const&)
{
return geometry::equals(g1, g2, typename Strategy::within_point_point_strategy_type());
}
};
template
struct equals
{
inline static bool apply(Geometry const& g1, Geometry const& g2, default_strategy const&)
{
return geometry::equals(g1, g2);
}
template
inline static bool apply(Geometry const& g1, Geometry const& g2, Strategy const&)
{
// NOTE: there is no strategy for equals(box, box) so pass dummy variable
// TODO: there should be a strategy even if it is the same for all CSes in case undefined_cs was used
return geometry::equals(g1, g2, 0);
}
};
template
struct equals
{
inline static bool apply(Geometry const& g1, Geometry const& g2, default_strategy const&)
{
return geometry::equals(g1, g2);
}
template
inline static bool apply(Geometry const& g1, Geometry const& g2, Strategy const& s)
{
return geometry::equals(g1, g2, s.get_relate_segment_segment_strategy());
}
};
template
struct equals
{
template
inline static bool apply(const Geometry * g1, const Geometry * g2, Strategy const&)
{
return g1 == g2;
}
};
template
struct equals
{
template
inline static bool apply(T const& v1, T const& v2, Strategy const&)
{
return v1 == v2;
}
};
template
struct equals
{
template
inline static bool apply(const T * v1, const T * v2, Strategy const&)
{
return v1 == v2;
}
};
template
struct tuple_equals
{
template
inline static bool apply(Tuple const& t1, Tuple const& t2, Strategy const& strategy)
{
typedef typename boost::tuples::element::type T;
return equals::apply(boost::get(t1), boost::get(t2), strategy)
&& tuple_equals::apply(t1, t2, strategy);
}
};
template
struct tuple_equals
{
template
inline static bool apply(Tuple const&, Tuple const&, Strategy const&)
{
return true;
}
};
// TODO: Consider this: Since equal_to<> is using geometry::equals() it's possible that
// two compared Indexables are not exactly the same! They will be spatially equal
// but not strictly equal. Consider 2 Segments with reversed order of points.
// Therefore it's possible that during the Value removal different value will be
// removed than the one that was passed.
/*!
\brief The function object comparing Values.
It compares Geometries using geometry::equals() function. Other types are compared using operator==.
The default version handles Values which are Indexables.
This template is also specialized for std::pair and boost::tuple<...>.
\tparam Value The type of objects which are compared by this function object.
\tparam IsIndexable If true, Values are compared using boost::geometry::equals() functions.
*/
template ::value>
struct equal_to
{
/*! \brief The type of result returned by function object. */
typedef bool result_type;
/*!
\brief Compare values. If Value is a Geometry geometry::equals() function is used.
\param l First value.
\param r Second value.
\return true if values are equal.
*/
template
inline bool operator()(Value const& l, Value const& r, Strategy const& strategy) const
{
return detail::equals::apply(l, r, strategy);
}
};
/*!
\brief The function object comparing Values.
This specialization compares values of type std::pair.
It compares pairs' first values, then second values.
\tparam T1 The first type.
\tparam T2 The second type.
*/
template
struct equal_to, false>
{
/*! \brief The type of result returned by function object. */
typedef bool result_type;
/*!
\brief Compare values. If pair<> Value member is a Geometry geometry::equals() function is used.
\param l First value.
\param r Second value.
\return true if values are equal.
*/
template
inline bool operator()(std::pair const& l, std::pair const& r,
Strategy const& strategy) const
{
return detail::equals::apply(l.first, r.first, strategy)
&& detail::equals::apply(l.second, r.second, strategy);
}
};
/*!
\brief The function object comparing Values.
This specialization compares values of type boost::tuple<...>.
It compares all members of the tuple from the first one to the last one.
*/
template
struct equal_to, false>
{
typedef boost::tuple value_type;
/*! \brief The type of result returned by function object. */
typedef bool result_type;
/*!
\brief Compare values. If tuple<> Value member is a Geometry geometry::equals() function is used.
\param l First value.
\param r Second value.
\return true if values are equal.
*/
template
inline bool operator()(value_type const& l, value_type const& r,
Strategy const& strategy) const
{
return detail::tuple_equals<
value_type, 0, boost::tuples::length::value
>::apply(l, r, strategy);
}
};
}}}} // namespace boost::geometry::index::detail
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include
namespace boost { namespace geometry { namespace index { namespace detail {
template
struct std_tuple_equals
{
template
inline static bool apply(Tuple const& t1, Tuple const& t2, Strategy const& strategy)
{
typedef typename std::tuple_element::type T;
return equals::apply(std::get(t1), std::get(t2), strategy)
&& std_tuple_equals::apply(t1, t2, strategy);
}
};
template
struct std_tuple_equals
{
template
inline static bool apply(Tuple const&, Tuple const&, Strategy const&)
{
return true;
}
};
/*!
\brief The function object comparing Values.
This specialization compares values of type std::tuple.
It's defined if the compiler supports tuples and variadic templates.
It compares all members of the tuple from the first one to the last one.
*/
template
struct equal_to, false>
{
typedef std::tuple value_type;
/*! \brief The type of result returned by function object. */
typedef bool result_type;
/*!
\brief Compare values. If tuple<> Value member is a Geometry geometry::equals() function is used.
\param l First value.
\param r Second value.
\return true if values are equal.
*/
template
bool operator()(value_type const& l, value_type const& r, Strategy const& strategy) const
{
return detail::std_tuple_equals<
value_type, 0, std::tuple_size::value
>::apply(l, r, strategy);
}
};
}}}} // namespace boost::geometry::index::detail
#endif // !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
namespace boost { namespace geometry { namespace index {
/*!
\brief The function object comparing Values.
The default version handles Values which are Indexables, std::pair, boost::tuple<...>
and std::tuple<...> if STD tuples and variadic templates are supported.
All members are compared from left to right, Geometries using boost::geometry::equals() function,
other types using operator==.
\tparam Value The type of objects which are compared by this function object.
*/
template
struct equal_to
: detail::equal_to
{
/*! \brief The type of result returned by function object. */
typedef typename detail::equal_to::result_type result_type;
/*!
\brief Compare Values.
\param l First value.
\param r Second value.
\return true if Values are equal.
*/
inline bool operator()(Value const& l, Value const& r) const
{
return detail::equal_to::operator()(l, r, default_strategy());
}
template
inline bool operator()(Value const& l, Value const& r, Strategy const& strategy) const
{
return detail::equal_to::operator()(l, r, strategy);
}
};
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_EQUAL_TO_HPP