Hello.
For a while I just could not successfully compile the code like:
xml_document< wchar_t > doc; // ok
:
doc.parse<0>( src ) ; // ok
:
std::wcout << doc << endl; // compile-time error
All the traces led to the following problematic code:
Unit: rapidxml_pring.hpp
Function:
template<class Ch>
inline std::basic_ostream<Ch> &print(std::basic_ostream<Ch> &out, const xml_node<Ch> &node, int flags = 0)
{
//..print(std::ostream_iterator<Ch>(out), node, flags); // <--- BUGGY
....print(std::ostream_iterator<Ch,Ch>(out), node, flags); // <-- FIXED
....return out;
}
If you look at the std::ostream_iterator<> declaration
template <
class Type
class CharType = char // N.B.!!!
class Traits = char_traits<CharType>
>
class ostream_iterator...
you may see that template argument ‘CharType’ has the value ‘char’ by default. This is why the rapidxml::print() is successfully compiled in <char> mode, but cannot be compiled in <wchar_t> mode.
So, as was writtend above to fix this bug we should supply ostream_iterator() ctor with the second template artument (instead of using the default ‘char’ argument):
//..print(std::ostream_iterator<Ch>(out), node, flags); // <--- BUGGY
....print(std::ostream_iterator<Ch,Ch>(out), node, flags); // <-- FIXED
Hope this fix will be included in the next version/update of rapidxml.