[bug] Output the range to an ostream

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[bug] Output the range to an ostream

Alexander Potocki
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

File boost/iterator/iterator_range.hpp

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,
   return Os;

Alexander Potocki
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost