SourceForge has been redesigned. Learn more.
Close

#5 Bug in rapidxml_print.hpp::print() (only in wchar_t mode)

open-fixed
nobody
None
5
2009-07-18
2009-07-16
No

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.

Discussion

  • Alex Mission

    Alex Mission - 2009-07-16
    • summary: Bug in rapidxml_pring.hpp::print() (only wchar_t mode is aff --> Bug in rapidxml_pring.hpp::print() (only in wchar_t mode)
     
  • Alex Mission

    Alex Mission - 2009-07-18

    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.

     
  • Alex Mission

    Alex Mission - 2009-07-18
    • summary: Bug in rapidxml_pring.hpp::print() (only in wchar_t mode) --> Bug in rapidxml_print.hpp::print() (only in wchar_t mode)
    • status: open --> open-fixed
     

Log in to post a comment.