From 6fab3bbfa4e970b53dd79ccef8ff35085a1fcd36 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Tue, 28 Jan 2025 00:29:35 +0300 Subject: [PATCH] Removed dependency on MPL from is_lvalue_iterator.hpp. Also removed workarounds for older compilers and simplified implementation. --- include/boost/iterator/is_lvalue_iterator.hpp | 142 +++++++----------- 1 file changed, 54 insertions(+), 88 deletions(-) diff --git a/include/boost/iterator/is_lvalue_iterator.hpp b/include/boost/iterator/is_lvalue_iterator.hpp index 260e21b..179de06 100644 --- a/include/boost/iterator/is_lvalue_iterator.hpp +++ b/include/boost/iterator/is_lvalue_iterator.hpp @@ -2,107 +2,73 @@ // 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 IS_LVALUE_ITERATOR_DWA2003112_HPP -# define IS_LVALUE_ITERATOR_DWA2003112_HPP - -#include +#define IS_LVALUE_ITERATOR_DWA2003112_HPP #include -#include #include #include namespace boost { - namespace iterators { +namespace detail { -namespace detail +// Guts of is_lvalue_iterator. It is the iterator type and +// Value is the iterator's value_type. +template< typename It, typename Value > +struct is_lvalue_iterator_impl : + public detail::conjunction< + std::is_convertible< decltype(*std::declval< It& >()), typename std::add_lvalue_reference< Value >::type >, + std::is_lvalue_reference< decltype(*std::declval< It& >()) > + >::type { - // Guts of is_lvalue_iterator. Value is the iterator's value_type - // and the result is computed in the nested rebind template. - template - struct is_lvalue_iterator_impl - { - template - using DerefT = decltype(*std::declval()); - - template - struct rebind : detail::conjunction< - std::is_convertible, typename std::add_lvalue_reference::type> - , std::is_lvalue_reference> - >::type - { - }; - }; - - // - // void specializations to handle std input and output iterators - // - template <> - struct is_lvalue_iterator_impl - { - template - struct rebind : std::false_type - {}; - }; - -#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS - template <> - struct is_lvalue_iterator_impl - { - template - struct rebind : std::false_type - {}; - }; - - template <> - struct is_lvalue_iterator_impl - { - template - struct rebind : std::false_type - {}; - }; - - template <> - struct is_lvalue_iterator_impl - { - template - struct rebind : std::false_type - {}; - }; -#endif - - // - // This level of dispatching is required for Borland. We might save - // an instantiation by removing it for others. - // - template - struct is_readable_lvalue_iterator_impl - : is_lvalue_iterator_impl< - BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type const - >::template rebind - {}; - - template - struct is_non_const_lvalue_iterator_impl - : is_lvalue_iterator_impl< - BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type - >::template rebind - {}; -} // namespace detail - -template< typename T > struct is_lvalue_iterator -: public std::integral_constant::value> -{ -public: - BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_lvalue_iterator,(T)) }; -template< typename T > struct is_non_const_lvalue_iterator -: public std::integral_constant::value> +// +// void specializations to handle std input and output iterators +// +template< typename It > +struct is_lvalue_iterator_impl< It, void > : + public std::false_type +{ +}; + +template< typename It > +struct is_lvalue_iterator_impl< It, const void > : + public std::false_type +{ +}; + +template< typename It > +struct is_lvalue_iterator_impl< It, volatile void > : + public std::false_type +{ +}; + +template< typename It > +struct is_lvalue_iterator_impl< It, const volatile void > : + public std::false_type +{ +}; + +} // namespace detail + +template< typename T > +struct is_lvalue_iterator : + public iterators::detail::is_lvalue_iterator_impl< + T, + typename std::iterator_traits< T >::value_type const + >::type +{ +}; + +template< typename T > +struct is_non_const_lvalue_iterator : + public iterators::detail::is_lvalue_iterator_impl< + T, + typename std::iterator_traits< T >::value_type + >::type { -public: - BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_non_const_lvalue_iterator,(T)) }; } // namespace iterators