mirror of
https://github.com/boostorg/iterator.git
synced 2025-05-11 05:23:52 +00:00
Reduced dependency on MPL in minimum_category.hpp.
This commit is contained in:
parent
7ddbf15868
commit
b30cbf634c
@ -2,61 +2,35 @@
|
|||||||
// subject to the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#ifndef BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_
|
#ifndef BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_
|
||||||
# define BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_
|
#define BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_
|
||||||
|
|
||||||
# include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <boost/mpl/arg_fwd.hpp>
|
||||||
# include <boost/mpl/placeholders.hpp>
|
|
||||||
# include <boost/mpl/aux_/lambda_support.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace iterators {
|
namespace iterators {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template <bool GreaterEqual, bool LessEqual>
|
template <class T1, class T2, bool GreaterEqual, bool LessEqual>
|
||||||
struct minimum_category_impl;
|
struct minimum_category_impl;
|
||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
struct error_not_related_by_convertibility;
|
struct minimum_category_impl<T1, T2, true, false>
|
||||||
|
|
||||||
template <>
|
|
||||||
struct minimum_category_impl<true,false>
|
|
||||||
{
|
{
|
||||||
template <class T1, class T2> struct apply
|
using type = T2;
|
||||||
{
|
|
||||||
typedef T2 type;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <class T1, class T2>
|
||||||
struct minimum_category_impl<false,true>
|
struct minimum_category_impl<T1, T2, false, true>
|
||||||
{
|
{
|
||||||
template <class T1, class T2> struct apply
|
using type = T1;
|
||||||
{
|
|
||||||
typedef T1 type;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <class T1, class T2>
|
||||||
struct minimum_category_impl<true,true>
|
struct minimum_category_impl<T1, T2, true, true>
|
||||||
{
|
{
|
||||||
template <class T1, class T2> struct apply
|
static_assert(std::is_same<T1, T2>::value, "Iterator category types must be the same when they are equivalent.");
|
||||||
{
|
using type = T1;
|
||||||
static_assert(
|
|
||||||
std::is_same<T1,T2>::value,
|
|
||||||
"Iterator category types must be the same when they are equivalent."
|
|
||||||
);
|
|
||||||
typedef T1 type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct minimum_category_impl<false,false>
|
|
||||||
{
|
|
||||||
template <class T1, class T2> struct apply
|
|
||||||
: error_not_related_by_convertibility<T1,T2>
|
|
||||||
{
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
@ -65,32 +39,30 @@ struct minimum_category_impl<false,false>
|
|||||||
// Returns the minimum category type or fails to compile
|
// Returns the minimum category type or fails to compile
|
||||||
// if T1 and T2 are unrelated.
|
// if T1 and T2 are unrelated.
|
||||||
//
|
//
|
||||||
template <class T1 = mpl::_1, class T2 = mpl::_2>
|
template< class T1 = mpl::arg<1>, class T2 = mpl::arg<2> >
|
||||||
struct minimum_category
|
struct minimum_category
|
||||||
{
|
{
|
||||||
typedef boost::iterators::detail::minimum_category_impl<
|
static_assert(
|
||||||
std::is_convertible<T1,T2>::value
|
std::is_convertible<T1, T2>::value || std::is_convertible<T2, T1>::value,
|
||||||
, std::is_convertible<T2,T1>::value
|
"Iterator category types must be related through convertibility.");
|
||||||
> outer;
|
|
||||||
|
|
||||||
typedef typename outer::template apply<T1,T2> inner;
|
using type = typename boost::iterators::detail::minimum_category_impl<
|
||||||
typedef typename inner::type type;
|
T1,
|
||||||
|
T2,
|
||||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(2,minimum_category,(T1,T2))
|
std::is_convertible<T1, T2>::value,
|
||||||
|
std::is_convertible<T2, T1>::value
|
||||||
|
>::type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct minimum_category<mpl::_1,mpl::_2>
|
struct minimum_category< mpl::arg<1>, mpl::arg<2> >
|
||||||
{
|
{
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
struct apply : minimum_category<T1,T2>
|
struct apply : minimum_category<T1, T2>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,minimum_category,(mpl::_1,mpl::_2))
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace iterators
|
} // namespace iterators
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif // BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_
|
#endif // BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_
|
||||||
|
Loading…
x
Reference in New Issue
Block a user