Boost logo

Boost :

From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2002-09-30 07:37:40


Hello,

the test macros of the new test library contain code of the form

boost::test_toolbox::detail::wrapstrstream() << message_

with wrapstrstream and operator<<() defined as

---%<---
struct wrapstrstream {
     mutable out_stringstream m_buf;
     mutable std::string m_str;

     std::string const& str() const;
};

template <class T>
inline wrapstrstream const&
operator<<( wrapstrstream const& targ, T const& t )
{
     targ.m_buf << t;
     return targ;
}
--->%---

The problem is, the temporary object wrapstrstream() is bound to the
const reference wrapstrstream const& targ which requires an accessible
copy constructor. But as out_stringstream is a typedef for
std::ostringstream and the stream classes are not copyable, the compiler
can't construct a copy constructor for wrapstrstream.

An easy fix probably would be to declare m_buf as
boost::shared_ptr<out_stringstream> and allocate the stream in the
constructor.

Comments, anyone?

TIA, Markus


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk