Skip to content

Commit 88c9723

Browse files
committed
Use perfect forwarding in assignment to operator_brackets_proxy.
Also apply noexcept markup to all of the proxy operators.
1 parent 7c77e52 commit 88c9723

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

include/boost/iterator/iterator_facade.hpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,21 +346,27 @@ class operator_brackets_proxy
346346
// Iterator is actually an iterator_facade, so we do not have to
347347
// go through iterator_traits to access the traits.
348348
using reference = typename Iterator::reference;
349-
using value_type = typename Iterator::value_type;
350349

351350
public:
352-
operator_brackets_proxy(Iterator const& iter) :
351+
explicit operator_brackets_proxy(Iterator const& iter) noexcept(std::is_nothrow_copy_constructible< Iterator >::value) :
353352
m_iter(iter)
354353
{}
355354

356-
operator reference() const
355+
operator reference() const noexcept(noexcept(*m_iter))
357356
{
358357
return *m_iter;
359358
}
360359

361-
operator_brackets_proxy& operator=(value_type const& val)
360+
template< typename T >
361+
typename std::enable_if<
362+
!std::is_same<
363+
operator_brackets_proxy< Iterator >,
364+
typename std::remove_cv< typename std::remove_reference< T >::type >::type
365+
>::value,
366+
operator_brackets_proxy&
367+
>::type operator= (T&& val) noexcept(std::is_nothrow_assignable< reference, T&& >::value)
362368
{
363-
*m_iter = val;
369+
*m_iter = static_cast< T&& >(val);
364370
return *this;
365371
}
366372

0 commit comments

Comments
 (0)