Boost logo

Boost :

From: Alexander Potocki (sane_at_[hidden])
Date: 2006-02-05 11:12:53


Hi boosters!

E.g. followed code can't be compiled

std::wstring ws(L"test");
boost::iterator_range<std::wstring::const_iterator> wrange(ws);
std::wcout << wrange; // compilation error here

It seems the implementation of operator << for iterator_range is not
correct:

File boost/iterator/iterator_range.hpp

#ifndef BOOST_OLD_IOSTREAMS
template< typename IteratorT, typename Elem, typename Traits >
inline std::basic_ostream<Elem,Traits>& operator<<(
                    std::basic_ostream<Elem, Traits>& Os,
                    const iterator_range<IteratorT>& r )
        {
           std::copy( r.begin(), r.end(), std::ostream_iterator<Elem>(Os));
            return Os;
        }
..

I guess the function body should be like this:
{
   typedef typename iterator_value<IteratorT>::type ValueType;
   std::copy( r.begin(), r.end(), std::ostream_iterator<ValueType, Elem,
Traits>(Os));
   return Os;
}

Regards,
Alexander Potocki


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