Boost logo

Boost :

From: Marvin H. Sielenkemper (sielenk_at_[hidden])
Date: 2004-11-16 15:09:07


I tried to compile the current boost libraries with VC8.0 beta. It stopped
and reported the following error:
---- SNIP ----
C:\Code\boost\boost\archive\iterators\xml_escape.hpp(47) : error C2440:
'type cast' : cannot convert from 'const wchar_t *' to
'std::_String_const_iterator<_Elem,_Traits,_Alloc>'
        with
        [
            _Elem=wchar_t,
            _Traits=std::char_traits<wchar_t>,
            _Alloc=std::allocator<wchar_t>
        ]
        No constructor could take the source type, or constructor overload
resolution was ambiguous
        C:\Code\boost\boost\archive\impl\xml_woarchive_impl.ipp(108) :
          see reference to function template instantiation
'boost::archive::iterators::xml_escape<Base>::xml_escape<const _Elem*>(T)'
being compiled
        with
        [
            Base=std::_String_const_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>,
            _Elem=wchar_t,
            T=const wchar_t *
        ]
        C:\Program Files\Microsoft Visual Studio 8\VC\include\xmemory(135) :
          while compiling class template member function 'void
boost::archive::xml_woarchive_impl<Archive>::save(const std::wstring &)'
        with
        [
            Archive=boost::archive::xml_woarchive
        ]
        C:\Code\boost\boost\archive\xml_woarchive.hpp(84) :
          see reference to class template instantiation
'boost::archive::xml_woarchive_impl<Archive>' being compiled
        with
        [
            Archive=boost::archive::xml_woarchive
        ]
---- SNIP ----

The problem seems to be the more restrictive STL implementation which
doesn't allow/use pointers as wstring iterators.

The following change fixed the problem for me:

Index: boost/archive/impl/xml_woarchive_impl.ipp
===================================================================
RCS file:
/cvsroot/boost/boost/boost/archive/impl/xml_woarchive_impl.ipp,v
retrieving revision 1.5
diff -u -w -b -r1.5 xml_woarchive_impl.ipp
--- boost/archive/impl/xml_woarchive_impl.ipp 7 Nov 2004 21:27:53 -0000
1.5
+++ boost/archive/impl/xml_woarchive_impl.ipp 16 Nov 2004 08:58:47 -0000
@@ -105,8 +105,8 @@
 void xml_woarchive_impl<Archive>::save(const std::wstring & ws){
     typedef iterators::xml_escape<std::wstring::const_iterator> xmbtows;
     std::copy(
- xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws.data())),
- xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws.data() + ws.size())),
+ xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws.begin())),
+ xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws.end())),
         boost::archive::iterators::ostream_iterator<wchar_t>(os)
     );
 }

Regards

Marvin H. Sielenkemper,
PROVISIO GmbH


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk