
Hi, I'm using boost 1.33.0 on windows (VC++6). I would like to use a code_converter to convert internal std::wstring's (which I understand are ucs2 in windows/vstudio, but that shouldn't matter here I guess) to utf-8 when saving to file. Here is the failing code: <code> void main() { typedef boost::iostreams::code_converter<boost::iostreams::file_sink, WideCharToUtf8Cvt> my_sink; std::wstring teststr(L"Blah blah."); boost::iostreams::filtering_wostream out; boost::iostreams::file_sink myFile("out.txt"); out.push(my_sink(myFile)); out << teststr; } </code> WideCharToUtf8Cvt is my own codecvt implementation. The problem is that I get a crash as the stream is being destroyed. The call stack is too deep to include here, but one of the last things are: policy_type& dev() { return **dev_; } in boost.iostreams.detail.code_converter_impl which calls boost::iostreams::detail::optional<boost::iostreams::detail::concept_adapter<boost::iostreams::basic_file_sink<char>
::operator*()
operator*() asserts on initialized_ which is false in this case. I've tried both with vc++6 sp5 and vc++ 7.1 with the same results. Also, there is no difference if I use this typedef for my_sink: typedef boost::iostreams::code_converter<boost::iostreams::file_sink> my_sink; so I don't think my codecvt implementation is to blame... The file out.txt actually gets filled with the expected data. Am I going about this the completely wrong way or am I just missing some important detail? Any help would be greatly appreciated, Niklas Wiberg