From bf4cce611454713f1c8e5f46a2c3e599c548656d Mon Sep 17 00:00:00 2001 From: Georgy Guminov Date: Sat, 25 Jan 2025 11:51:32 +0300 Subject: [PATCH] Refactor is_lvalue_iterator.hpp. --- include/boost/iterator/is_lvalue_iterator.hpp | 43 ++++--------------- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/include/boost/iterator/is_lvalue_iterator.hpp b/include/boost/iterator/is_lvalue_iterator.hpp index 3b52e46..3e4b22f 100644 --- a/include/boost/iterator/is_lvalue_iterator.hpp +++ b/include/boost/iterator/is_lvalue_iterator.hpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include @@ -18,47 +18,20 @@ namespace iterators { namespace detail { - // Calling lvalue_preserver( , 0 ) returns a reference - // to the expression's result if is an lvalue, or - // not_an_lvalue() otherwise. - struct not_an_lvalue {}; - - template - T& lvalue_preserver(T&, int); - - template - not_an_lvalue lvalue_preserver(U const&, ...); - // 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 - { - // Eat implicit conversions so we don't report true for things - // convertible to Value const& - struct conversion_eater - { - conversion_eater(typename std::add_lvalue_reference::type); - }; - - static char tester(conversion_eater, int); - static char (& tester(any_conversion_eater, ...) )[2]; + { + template + using DerefT = decltype(*std::declval()); template - struct rebind + struct rebind : detail::conjunction< + std::is_convertible, typename std::add_lvalue_reference::type> + , std::is_lvalue_reference> + >::type { - static It& x; - - BOOST_STATIC_CONSTANT( - bool - , value = ( - sizeof( - is_lvalue_iterator_impl::tester( - detail::lvalue_preserver(*x,0), 0 - ) - ) == 1 - ) - ); }; };