Boost logo

Boost :

From: Alberto Ganesh Barbati (abarbati_at_[hidden])
Date: 2005-11-02 17:44:36


Jonathan Turkanis wrote:
>
> My recollection is that all the is_open() functions should be const, so I'm
> inclined to change [in]direct_streambuf. Could you give me an example of
> something that won't currently compile, but should?
>

For example this:

----- test.cpp
#include <boost/iostreams/stream.hpp>

namespace io = boost::iostreams;

class empty_source
{
public:
  typedef char char_type;
  typedef io::source_tag category;

  empty_source(int) {}
  std::streamsize read(char* s, std::streamsize n) { return -1; }
};

int main()
{
  io::stream<empty_source> s(0);
  s.is_open();
}
----- test.cpp

On Vc7.1 it produces the error:

c:\lib\Boost\include\boost-1_33\boost\iostreams\stream.hpp(113) : error
C2662:
'boost::iostreams::detail::indirect_streambuf<T,Tr,Alloc,Mode>::is_open'
: cannot convert 'this' pointer from 'const
boost::iostreams::stream_buffer<T,Tr,Alloc>' to
'boost::iostreams::detail::indirect_streambuf<T,Tr,Alloc,Mode> &'

If you change the category to:

 struct category : io::source_tag, io::direct_tag {};

you'll get the same problem for direct_streambuf.

HTH,

Ganesh


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