Boost logo

Boost :

Subject: Re: [boost] Iostreams Code converter bug
From: Daniel James (dnljms_at_[hidden])
Date: 2011-02-03 07:07:16


On 3 February 2011 00:35, Eddie Carle <eddie_at_[hidden]> wrote:
>
> Although there is commenting explaining what BOOST_IOSTREAMS_FORWARD
> does, there is no comments explaining what
> BOOST_IOSTREAMS_FORWARDING_CTOR is and what all that macro code actually
> does. I can't run it through a debugger so I've hit a wall as far as
> fixing this. Can anyone offer any insight as to what is going on here?
> What is this BOOST_IOSTREAMS_FORWARDING_CTOR macro?

The best way of finding out what complicated macros do is to run it
through the preprocessor, find the generated code and the run that
through a code beautifier if necessary.

In this case it seems to be creating constructors which take a
variable number of arguments for forwarding to the device constructor,
followed by the buffer size. I guess that the problem is that the
buffer size argument is actually an int (see
BOOST_IOSTREAMS_CONVERTER_PARAMS), and that 'std::streamsize' is
something else (try casting the buffer size to an int when
constructing the class). So since the buffer size parameter is
optional, and the template arguments for forwarding to the device
constructor are probably a better match, what you want to be the
buffer size is used as a parameter for the device constructor.

I'm not sure what a good solution is. Having variadic arguments
followed by an optional argument is a really bad idea, it's far too
ambiguous. Since it isn't documented, it might be possible just to
remove the feature but that could cause problems for other people. I'd
be tempted to create a new class with a simpler interface but the same
implementation behind it.

Daniel


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