Move is_range util to range.hpp to avoid Boost.Range/MPL dependency in type_traits.hpp

This commit is contained in:
Adam Wulkiewicz 2020-09-03 13:57:57 +02:00
parent 0dc6ee14d3
commit c63e7a8394
7 changed files with 50 additions and 47 deletions

View File

@ -30,7 +30,7 @@ namespace detail
{
template <typename T, bool IsRange = is_range<T>::value>
template <typename T, bool IsRange = range::detail::is_range<T>::value>
struct is_tupled_output_element_base
: bool_constant<false>
{};

View File

@ -19,7 +19,7 @@
namespace boost { namespace geometry { namespace index { namespace detail {
//template <typename T, typename V, bool IsRange = geometry::detail::is_range<T>::value>
//template <typename T, typename V, bool IsRange = range::detail::is_range<T>::value>
//struct is_range_of_convertible_values_impl
// : std::is_convertible<typename ::boost::range_value<T>::type, V>
//{};

View File

@ -92,6 +92,7 @@
#include <boost/geometry/index/detail/serialization.hpp>
#endif
#include <boost/geometry/util/range.hpp>
#include <boost/geometry/util/type_traits.hpp>
// TODO change the name to bounding_tree
@ -1832,7 +1833,7 @@ private:
inline void insert_dispatch(Range const& rng,
std::false_type /*is_convertible*/)
{
BOOST_MPL_ASSERT_MSG((geometry::detail::is_range<Range>::value),
BOOST_MPL_ASSERT_MSG((range::detail::is_range<Range>::value),
PASSED_OBJECT_IS_NOT_CONVERTIBLE_TO_VALUE_NOR_A_RANGE,
(Range));
@ -1868,7 +1869,7 @@ private:
inline size_type remove_dispatch(Range const& rng,
std::false_type /*is_convertible*/)
{
BOOST_MPL_ASSERT_MSG((geometry::detail::is_range<Range>::value),
BOOST_MPL_ASSERT_MSG((range::detail::is_range<Range>::value),
PASSED_OBJECT_IS_NOT_CONVERTIBLE_TO_VALUE_NOR_A_RANGE,
(Range));

View File

@ -24,6 +24,8 @@
#include <boost/geometry/srs/sphere.hpp>
#include <boost/geometry/srs/spheroid.hpp>
#include <boost/geometry/util/range.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
@ -74,7 +76,7 @@ template
<
typename Range,
typename ToValue,
bool IsRange = boost::has_range_iterator<Range>::value
bool IsRange = range::detail::is_range<Range>::value
>
struct is_convertible_range
: std::is_convertible

View File

@ -21,11 +21,13 @@
#include <boost/concept_check.hpp>
#include <boost/config.hpp>
#include <boost/core/addressof.hpp>
#include <boost/mpl/has_xxx.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/empty.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/range/has_range_iterator.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/rbegin.hpp>
#include <boost/range/reference.hpp>
@ -35,9 +37,44 @@
#include <boost/geometry/core/assert.hpp>
#include <boost/geometry/core/mutable_range.hpp>
namespace boost { namespace geometry { namespace range {
namespace boost { namespace geometry { namespace range
{
namespace detail
{
BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category)
template <typename T>
struct is_iterator
: std::integral_constant
<
bool,
has_iterator_category
<
std::iterator_traits<T>
>::value
>
{};
template <typename T, bool HasIterator = boost::has_range_iterator<T>::value>
struct is_range_impl
: is_iterator
<
typename boost::range_iterator<T>::type
>
{};
template <typename T>
struct is_range_impl<T, false>
: std::false_type
{};
template <typename T>
struct is_range
: is_range_impl<T>
{};
namespace detail {
// NOTE: For SinglePassRanges pos could iterate over all elements until the i-th element was met.

View File

@ -12,15 +12,11 @@
#include <cstddef>
#include <iterator>
#include <type_traits>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/mpl/has_xxx.hpp>
#include <boost/range/has_range_iterator.hpp>
namespace boost { namespace geometry
{
@ -293,39 +289,6 @@ using enable_if_polysegmental_t = typename enable_if_polysegmental<Geometry, T>:
BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category)
template <typename T>
struct is_iterator
: bool_constant
<
has_iterator_category
<
std::iterator_traits<T>
>::value
>
{};
template <typename T, bool HasIterator = boost::has_range_iterator<T>::value>
struct is_range_impl
: is_iterator
<
typename boost::range_iterator<T>::type
>
{};
template <typename T>
struct is_range_impl<T, false>
: std::false_type
{};
template <typename T>
struct is_range
: is_range_impl<T>
{};
// C++20
template <typename T>
struct remove_cvref

View File

@ -73,9 +73,9 @@ int test_main(int, char* [])
typedef bg::model::multi_linestring<linestring> multi_linestring;
//typedef bg::model::multi_polygon<polygon> multi_polygon;
BOOST_CHECK_EQUAL((bgd::is_range<int>::value), false);
BOOST_CHECK_EQUAL((bgd::is_range<linestring>::value), true);
BOOST_CHECK_EQUAL((bgd::is_range<multi_point>::value), true);
BOOST_CHECK_EQUAL((bg::range::detail::is_range<int>::value), false);
BOOST_CHECK_EQUAL((bg::range::detail::is_range<linestring>::value), true);
BOOST_CHECK_EQUAL((bg::range::detail::is_range<multi_point>::value), true);
BOOST_CHECK_EQUAL((bgd::is_tupled_output_element<int>::value), false);
BOOST_CHECK_EQUAL((bgd::is_tupled_output_element<linestring>::value), false);