From 01ac4e1a47597549c5776b194e4eea8d86aea8ca Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Mon, 9 Jun 2025 11:59:05 +0300 Subject: [PATCH] Disable operator_brackets_proxy assignment if reference is not assignable. Use SFINAE to disable operator_brackets_proxy assignment operator is reference is not assignable from the assignment argument. Also fix the iterator type in std::declval in noexcept specification. --- include/boost/iterator/iterator_facade.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/boost/iterator/iterator_facade.hpp b/include/boost/iterator/iterator_facade.hpp index 0c6b356..bb0360e 100644 --- a/include/boost/iterator/iterator_facade.hpp +++ b/include/boost/iterator/iterator_facade.hpp @@ -360,12 +360,17 @@ public: template< typename T > typename std::enable_if< - !std::is_same< - operator_brackets_proxy< Iterator >, - typename std::remove_cv< typename std::remove_reference< T >::type >::type + detail::conjunction< + detail::negation< + std::is_same< + operator_brackets_proxy< Iterator >, + typename std::remove_cv< typename std::remove_reference< T >::type >::type + > + >, + std::is_assignable< reference, T&& > >::value, operator_brackets_proxy& - >::type operator= (T&& val) noexcept(noexcept(*std::declval< Iterator const& >() = std::declval< T&& >())) + >::type operator= (T&& val) noexcept(noexcept(*std::declval< Iterator& >() = std::declval< T&& >())) { *m_iter = static_cast< T&& >(val); return *this;