[Boost-bugs] [Boost C++ Libraries] #8315: tee function template does not work for std streams

Subject: [Boost-bugs] [Boost C++ Libraries] #8315: tee function template does not work for std streams
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-03-20 14:24:37


#8315: tee function template does not work for std streams
------------------------------+---------------------------------------------
 Reporter: Claudio Bley | Owner: turkanis
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: iostreams
  Version: Boost 1.53.0 | Severity: Problem
 Keywords: tee iostreams |
------------------------------+---------------------------------------------
 = General Info =

 OS:: Windows 7 64bit

 Compiler:: MSVC 10

 = The Code =
 {{{
 #!cpp
 std::ostringstream out;
 boost::iostreams::tee(out);
 }}}

 = Compiler Output / Error =

 {{{
 Boost\Boost_1_53\boost/iostreams/tee.hpp(208): error C2440: '<function-
 style-cast>' : cannot convert from 'const std::ostringstream' to
 'boost::iostreams::tee_filter<Device>'
  with
  [
      Device=std::ostringstream
  ]
  No constructor could take the source type, or constructor overload
 resolution was ambiguous
  recurse.cpp(14) : see reference to function template instantiation
 'boost::iostreams::tee_filter<Device>
 boost::iostreams::tee<std::ostringstream>(const Sink &)' being compiled
  with
  [
      Device=std::ostringstream,
      Sink=std::ostringstream
  ]
 }}}

 = Analysis =

 The parameter is given to the tee function template as a const-reference:
 {{{
 #!cpp
 template<typename Sink>
 tee_filter<Sink> tee(const Sink& snk)
 { return tee_filter<Sink>(snk); }
 }}}
 Quoting the documentation:

   The function parameter is a non-const reference if Sink is a stream
   or stream buffer type, and a const reference otherwise.

 Actually, this really does not apply to the function parameter, but rather
 to the tee_filter ctor parameter.

 So, this boils down to passing a const-reference type to a non-const-
 reference type as an argument.

 = Proposed Solution =

 Remove the "const" qualifier from the tee function parameter(s).

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8315>
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:12 UTC