| 1 | #include <boost/iostreams/stream.hpp>
|
|---|
| 2 | #include <boost/iostreams/device/file.hpp>
|
|---|
| 3 | #include <ios>
|
|---|
| 4 | #include <iostream>
|
|---|
| 5 | #include <boost/version.hpp>
|
|---|
| 6 |
|
|---|
| 7 | int main()
|
|---|
| 8 | {
|
|---|
| 9 | try
|
|---|
| 10 | {
|
|---|
| 11 | using namespace boost::iostreams;
|
|---|
| 12 | stream<file_sink> stream( "/wrong.txt" );
|
|---|
| 13 | std::cout << "boost ver:" << BOOST_LIB_VERSION << std::endl;
|
|---|
| 14 | std::cout << stream.fail() << ' ' << stream.bad() << std::endl;
|
|---|
| 15 | stream.exceptions( std::ios::badbit | std::ios::failbit );
|
|---|
| 16 | stream << "test" << std::endl;
|
|---|
| 17 | stream.close();
|
|---|
| 18 | std::cout << "nothing thrown" << std::endl;
|
|---|
| 19 | }
|
|---|
| 20 | catch(...)
|
|---|
| 21 | {
|
|---|
| 22 | std::cout << "exception catched" << std::endl;
|
|---|
| 23 | }
|
|---|
| 24 | return 0;
|
|---|
| 25 | }
|
|---|