[iostreams] array_sink

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[iostreams] array_sink

Jeff Flinn
My reading of the docs states that array_sink models the concept sink,
meaning that the following should compile:

#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/operations.hpp>

namespace io = boost::iostreams;

int main( int argc, char* argv[] )
{
      char x[4] = {};

      io::array_sink lSink(x,4);

      const char* y = "abc";

      io::write( lSink, y, 4 );

  return 0;
}

I must be doing something obviously wrong, on VC7.1 I get:

c:\boost\boost_1_33_1\boost\iostreams\write.hpp(118) : error C2039: 'write'
: is not a member of 'boost::iostreams::basic_array_sink<Ch>'
        with
        [
            Ch=char
        ]
        c:\boost\boost_1_33_1\boost\iostreams\write.hpp(52) : see reference
to function template instantiation 'std::streamsize
boost::iostreams::detail::write_device_impl<boost::iostreams::output>::write<boost::unwrap_reference<T>::type>(T
&,const boost::iostreams::detail::member_char_type<T>::type
*,std::streamsize)' being compiled
        with
        [
            T=boost::iostreams::array_sink
        ]
        c:\dev\AAA - Advantage
New\DasNew\DasClientTest\DasClientTest.cpp(36) : see reference to function
template instantiation 'std::streamsize
boost::iostreams::write<boost::iostreams::array_sink>(T &,const
boost::iostreams::detail::member_char_type<T>::type *,std::streamsize)'
being compiled
        with
        [
            T=boost::iostreams::array_sink
        ]

Any thoughts are appreciated.

Thanks, Jeff



_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [iostreams] array_sink

EMalenfant
From: Jeff Flinn [mailto:[hidden email]]
>
> My reading of the docs states that array_sink models the
> concept sink, meaning that the following should compile:
>
[snip]
>
>       io::array_sink lSink(x,4);
>
>       const char* y = "abc";
>
>       io::write( lSink, y, 4 );
[snip]
>
> I must be doing something obviously wrong, on VC7.1 I get:
>
> c:\boost\boost_1_33_1\boost\iostreams\write.hpp(118) : error
> C2039: 'write'
> : is not a member of 'boost::iostreams::basic_array_sink<Ch>'
[snip]

Hi Jeff,

I think this is related to the fact that array_sink is a "direct" sink.
At the bottom of this page:
http://www.boost.org/libs/iostreams/doc/?path=4.1.1.7 there is mention that
"io::write()" is subject the the precondition that the sink is *not*
convertible to "direct_tag".

BTW, in the "details" of the iostreams library, there is a "direct_adapter"
which seems to allow one to expose a "direct" Device as an "indirect" one.

HTH,

√Čric Malenfant

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [iostreams] array_sink

Jeff Flinn
Eric,

[hidden email] wrote:

> From: Jeff Flinn [mailto:[hidden email]]
>>
>> My reading of the docs states that array_sink models the
>> concept sink, meaning that the following should compile:
>>
> [snip]
>>
>>       io::array_sink lSink(x,4);
>>
>>       const char* y = "abc";
>>
>>       io::write( lSink, y, 4 );

[snip]

> I think this is related to the fact that array_sink is a "direct"
> sink.
> At the bottom of this page:
> http://www.boost.org/libs/iostreams/doc/?path=4.1.1.7 there is
> mention that "io::write()" is subject the the precondition that the
> sink is *not* convertible to "direct_tag".

Aarrgh, just when I thought I understood "concepts"...

> BTW, in the "details" of the iostreams library, there is a
> "direct_adapter" which seems to allow one to expose a "direct" Device
> as an "indirect" one.

Thanks for the info, I'll check it out. I assume that this is more efficient
than using an io::stream_buffer?

Thanks, Jeff



_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users