Ticket #2449: IoStreams.cpp

File IoStreams.cpp, 666 bytes (added by rbock@…, 14 years ago)

A short sample showing that filtering_istream::tellg() does not work (and corrupts the stream).

Line 
1#include <iostream>
2#include <string>
3#include <boost/iostreams/filtering_stream.hpp>
4#include <boost/iostreams/stream.hpp>
5#include <boost/iostreams/device/array.hpp>
6
7/*
8 * Expected Output:
9 * fis.good(): 1
10 * fis.tellg(): 0
11 * fis.good(): 1
12 *
13 * Received Output:
14 * fis.good(): 1
15 * fis.tellg(): -1
16 * fis.good(): 0
17 */
18
19int main()
20{
21 std::string test("Hello world");
22
23 boost::iostreams::filtering_istream fis;
24 fis.push(boost::make_iterator_range(test));
25
26 std::cerr << "fis.good(): " << fis.good() << std::endl;
27 std::cerr << "fis.tellg(): " << fis.tellg() << std::endl;
28 std::cerr << "fis.good(): " << fis.good() << std::endl;
29
30 return 0;
31}
32