Opened 17 years ago

Closed 17 years ago

#560 closed Bugs (None)

bug in output the range to an ostream

Reported by: e-poison Owned by: Thorsten Ottosen
Milestone: Component: iterator
Version: None Severity:
Keywords: Cc:

Description

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;
}

Change History (2)

comment:1 by nobody, 17 years ago

Logged In: NO 

fixed

comment:2 by sf-robot, 17 years ago

Status: assignedclosed
Logged In: YES 
user_id=1312539

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
Note: See TracTickets for help on using tickets.