Re: [Boost-bugs] [Boost C++ Libraries] #8463: function_output_iterator: MSVC warning C4512

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8463: function_output_iterator: MSVC warning C4512
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-05-24 00:19:41


#8463: function_output_iterator: MSVC warning C4512
---------------------------------------------------------------------------+
  Reporter: Mike Cowperthwaite <michael.cowperthwaite@…> | Owner: jeffrey.hellrung
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: iterator
   Version: Boost 1.52.0 | Severity: Problem
Resolution: | Keywords:
---------------------------------------------------------------------------+

Comment (by Paul Saville <boost_8463@…>):

 MSVC emits warning C4512 because output_proxy contains a reference member
 variable, which makes default member-wise assignment impossible. I don't
 yet understand why the compiler refuses to use the operator= template
 member function to generate an acceptable (although apparently flawed)
 assignment operator. Changing the UnaryFunction reference to an ordinary
 member variable made the warning go away for me. This changes the
 behaviour so it's not a fix, just an experiment. I also added an assert()
 to determine whether the operator= template is ever actually called at
 runtime.

 {{{
   struct output_proxy
   {
     output_proxy( UnaryFunction& f ) : m_f( f ) {}
     template< class T > output_proxy& operator=( const T& value )
     {
       m_f( value );
       assert( false );
       return *this;
     }
 // UnaryFunction& m_f;
     UnaryFunction m_f;
   };
 }}}

 I'm also somewhat concerned about function_output_iterator::operator*().
 It returns an output_proxy instance containing a reference to private
 member function_output_iterator::m_f, which is a strange thing to do. If
 there is an esoteric idiom in play here, can anyone point out what it is?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8463#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC