Skip to content

Commit da00617

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 da00617

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

include/boost/iterator/iterator_facade.hpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <cstddef>
1111
#include <memory>
12+
#include <utility>
1213
#include <type_traits>
1314

1415
#include <boost/config.hpp>
@@ -346,21 +347,27 @@ class operator_brackets_proxy
346347
// Iterator is actually an iterator_facade, so we do not have to
347348
// go through iterator_traits to access the traits.
348349
using reference = typename Iterator::reference;
349-
using value_type = typename Iterator::value_type;
350350

351351
public:
352-
operator_brackets_proxy(Iterator const& iter) :
352+
explicit operator_brackets_proxy(Iterator const& iter) noexcept(std::is_nothrow_copy_constructible< Iterator >::value) :
353353
m_iter(iter)
354354
{}
355355

356-
operator reference() const
356+
operator reference() const noexcept(noexcept(*std::declval< Iterator const& >()))
357357
{
358358
return *m_iter;
359359
}
360360

361-
operator_brackets_proxy& operator=(value_type const& val)
361+
template< typename T >
362+
typename std::enable_if<
363+
!std::is_same<
364+
operator_brackets_proxy< Iterator >,
365+
typename std::remove_cv< typename std::remove_reference< T >::type >::type
366+
>::value,
367+
operator_brackets_proxy&
368+
>::type operator= (T&& val) noexcept(std::is_nothrow_assignable< reference, T&& >::value)
362369
{
363-
*m_iter = val;
370+
*m_iter = static_cast< T&& >(val);
364371
return *this;
365372
}
366373

0 commit comments

Comments
 (0)