
Jonathan, I am trying to build some of your samples with _UNICODE;UNICODE defined using Visual Studio 2003 and get a build error which is included in detail at the end of this message. Since you do not provide a Unicode sample I have modified your sample to support the Windows _TCHAR macros. The modified source code also is included at the end of this message. The code compiles and runs when _UNICODE is not defined. The build error occurs only with the Unicode build. Regards, George. Compiling... line_wrapping_example.cpp h:\source code\Turkanis\iostream\boost\io\detail\chain.hpp(169) : error C2664: 'std::list<_Ty>::push_back' : cannot convert parameter 1 from 'facade_type *' to 'boost::io::detail::linked_streambuf<Ch> & ' with [ _Ty=boost::io::detail::chain_base<boost::io::detail::chain<boost::io::output,wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>,wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>,boost::io::output>::streambuf_type * ] and [ Ch=wchar_t ] Reason: cannot convert from 'facade_type *' to 'boost::io::detail::linked_streambuf<Ch> ' with [ Ch=wchar_t ] Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast h:\source code\Turkanis\iostream\boost\io\detail\chain.hpp(134) : see reference to function template instantiation 'void boost::io::detail::chain_base<Self,Ch,Tr,Alloc,Mode>::push_impl<T>(const T &,std::streamsize,std::streamsize)' being compiled with [ Self=boost::io::detail::chain<boost::io::output,wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>, Ch=wchar_t, Tr=std::char_traits<wchar_t>, Alloc=std::allocator<wchar_t>, Mode=boost::io::output, T=boost::io::example::line_wrapping_output_filter ] h:\source code\Turkanis\iostream\boost\io\detail\chain.hpp(317) : see reference to function template instantiation 'void boost::io::detail::chain_base<Self,Ch,Tr,Alloc,Mode>::push<T>(const T &,std::streamsize,std::streamsize,boost::disable_if_c<B,void>::type *)' being compiled with [ Self=boost::io::detail::chain<boost::io::output,wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>, Ch=wchar_t, Tr=std::char_traits<wchar_t>, Alloc=std::allocator<wchar_t>, Mode=boost::io::output, T=boost::io::example::line_wrapping_output_filter, B=false ] h:\source code\Turkanis\iostream\boost\io\detail\chain.hpp(310) : see reference to function template instantiation 'void boost::io::detail::chain_client<Chain>::push_impl<T>(const T &,std::streamsize,std::streamsize)' being compiled with [ Chain=boost::io::detail::chain<boost::io::output,wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>, T=boost::io::example::line_wrapping_output_filter ] h:\Projects\Turkanis\example\line_wrapping_example\line_wrapping_example.cpp(46) : see reference to function template instantiation 'void boost::io::detail::chain_client<Chain>::push<boost::io::example::line_wrapping_output_filter>(const T &,std::streamsize,std::streamsize,boost::disable_if_c<B,void>::type *)' being compiled with [ Chain=boost::io::detail::chain<boost::io::output,wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>, T=boost::io::example::line_wrapping_output_filter, B=false ] //line_wrapping_output_filter.hpp #ifndef BOOST_IO_EXAMPLE_LINE_WRAPPING_OUTPUT_FILTER_HPP_INCLUDED #define BOOST_IO_EXAMPLE_LINE_WRAPPING_OUTPUT_FILTER_HPP_INCLUDED #include <boost/io/concepts.hpp> // output_filter. #include <boost/io/operations.hpp> // boost::io::put. namespace boost { namespace io { namespace example { class line_wrapping_output_filter : public output_filter { public: explicit line_wrapping_output_filter(int line_length = 80) : line_length_(line_length), col_no_(0) { } template<typename Sink> void put(Sink& dest, int c) { if (c == __T('\n')) col_no_ = 0 ; else { if (col_no_ >= line_length_) this->put(dest, __T('\n')); ++col_no_ ; } boost::io::put(dest, c); } template<typename Sink> void close(Sink& dest) { boost::io::put(dest, __T('\n')); col_no_ = 0; } private: int line_length_ ; int col_no_; }; } } } // End namespaces example, io, boost. #endif // #ifndef BOOST_IO_EXAMPLE_LINE_WRAPPING_OUTPUT_FILTER_HPP_INCLUDED //line_wrapping_filter.cpp #include <windows.h> #include <tchar.h> #include <iostream> #include <boost/io/filtering_stream.hpp> #include "line_wrapping_output_filter.hpp" #ifdef _UNICODE #define filtering_tostream filtering_wostream #define _tcout wcout #else #define filtering_tostream filtering_ostream #define _tcout cout #endif //_UNICODE // // Demonstrates the use of line_wrapping_output_filter. // void test_line_wrapping() { using namespace std; using namespace boost::io; using namespace boost::io::example; const _TCHAR* text = __T("In the country of Westphalia, in the castle of the most noble Baron ") __T("of Thunder-ten-tronckh, lived a youth whom Nature had endowed with a ") __T("most sweet disposition. His face was the true index of his mind. He ") __T("had a solid judgment joined to the most unaffected simplicity; and ") __T("hence, I presume, he had his name of Candide. The old servants of the ") __T("house suspected him to have been the son of the Baron's sister, by a ") __T("very good sort of a gentleman of the neighborhood, whom that young ") __T("lady refused to marry, because he could produce no more than ") __T("threescore and eleven quarterings in his arms; the rest of the ") __T("genealogical tree belonging to the family having been lost through ") __T("the injuries of time....\n"); filtering_tostream out; out.push(line_wrapping_output_filter(50)); out.push(_tcout); // Print unfiltered text. _tcout << __T("**** Candide ****\n\n") << text << __T("\n\n"); // Print filtered text: out << __T("**** Candide with line wrapping ****\n\n") << text << __T("\n\n"); } int _tmain() { test_line_wrapping(); return 0; }