Removed MPL usage from pointee and indirect_reference.

This commit is contained in:
Andrey Semashev
2025-01-26 17:57:47 +03:00
parent d6297a553b
commit bcf94f9e5d
2 changed files with 47 additions and 49 deletions

View File

@ -13,27 +13,28 @@
#include <boost/detail/is_incrementable.hpp> #include <boost/detail/is_incrementable.hpp>
#include <boost/iterator/iterator_traits.hpp> #include <boost/iterator/iterator_traits.hpp>
# include <boost/mpl/eval_if.hpp>
#include <boost/pointee.hpp> #include <boost/pointee.hpp>
namespace boost { #include <type_traits>
namespace detail namespace boost {
{ namespace detail {
template <class P>
template< typename P >
struct smart_ptr_reference struct smart_ptr_reference
{ {
typedef typename boost::pointee<P>::type& type; using type = typename boost::pointee<P>::type&;
}; };
}
template <class P> } // namespace detail
struct indirect_reference
: mpl::eval_if< template< typename P >
detail::is_incrementable<P> struct indirect_reference :
, iterator_reference<P> std::conditional<
, detail::smart_ptr_reference<P> detail::is_incrementable<P>::value,
> iterator_reference<P>,
detail::smart_ptr_reference<P>
>::type
{ {
}; };

View File

@ -15,43 +15,40 @@
#include <boost/detail/is_incrementable.hpp> #include <boost/detail/is_incrementable.hpp>
#include <boost/iterator/iterator_traits.hpp> #include <boost/iterator/iterator_traits.hpp>
# include <boost/mpl/eval_if.hpp>
#include <iterator> #include <iterator>
#include <type_traits> #include <type_traits>
namespace boost { namespace boost {
namespace detail {
namespace detail template< typename P >
{
template <class P>
struct smart_ptr_pointee struct smart_ptr_pointee
{ {
typedef typename P::element_type type; using type = typename P::element_type;
}; };
template <class Iterator> template< typename Iterator, typename = typename std::remove_reference<decltype(*std::declval<Iterator&>())>::type >
struct iterator_pointee struct iterator_pointee
{ {
typedef typename std::iterator_traits<Iterator>::value_type value_type; using type = typename std::iterator_traits<Iterator>::value_type;
typedef typename std::conditional<
std::is_const<
typename std::remove_reference<decltype(*std::declval<Iterator&>())>::type
>::value
, typename std::add_const<value_type>::type
, value_type
>::type type;
}; };
}
template <class P> template< typename Iterator, typename Reference >
struct pointee struct iterator_pointee< Iterator, const Reference >
: mpl::eval_if< {
detail::is_incrementable<P> using type = typename std::add_const<typename std::iterator_traits<Iterator>::value_type>::type;
, detail::iterator_pointee<P> };
, detail::smart_ptr_pointee<P>
> } // namespace detail
template< typename P >
struct pointee :
public std::conditional<
detail::is_incrementable<P>::value,
detail::iterator_pointee<P>,
detail::smart_ptr_pointee<P>
>::type
{ {
}; };