Disabled assignment of output_proxy to output_proxy.

This commit is contained in:
Andrey Semashev 2022-07-01 00:13:32 +03:00
parent ee2d3a6596
commit 1a80896934

View File

@ -13,6 +13,10 @@
#include <iterator>
#include <boost/config.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_reference.hpp>
namespace boost {
namespace iterators {
@ -24,20 +28,31 @@ namespace iterators {
class output_proxy {
public:
explicit output_proxy(UnaryFunction& f) : m_f(f) { }
explicit output_proxy(UnaryFunction& f) BOOST_NOEXCEPT : m_f(f) { }
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
template <class T> output_proxy& operator=(const T& value) {
template <class T>
typename boost::disable_if_c<
boost::is_same< typename boost::remove_cv< T >::type, output_proxy >::value,
output_proxy&
>::type operator=(const T& value) {
m_f(value);
return *this;
}
#else
template <class T> output_proxy& operator=(T&& value) {
template <class T>
typename boost::disable_if_c<
boost::is_same< typename boost::remove_cv< typename boost::remove_reference< T >::type >::type, output_proxy >::value,
output_proxy&
>::type operator=(T&& value) {
m_f(static_cast< T&& >(value));
return *this;
}
#endif
BOOST_DEFAULTED_FUNCTION(output_proxy(output_proxy const& that), BOOST_NOEXCEPT : m_f(that.m_f) {})
BOOST_DELETED_FUNCTION(output_proxy& operator=(output_proxy const&))
private:
UnaryFunction& m_f;
};