Следующая программа:
#include <boost/range/concepts.hpp>
#include <iterator>
#include <istream>
using boost::range_detail::SinglePassIteratorConcept;
int main()
{
BOOST_CONCEPT_ASSERT(( SinglePassIteratorConcept<std::istreambuf_iterator<char>> ));
}
Не в состоянии скомпилировать как MSVC, так и gcc.Ошибка MSVC выглядит следующим образом:
D:\libraries\boost\boost/range/concepts.hpp(157) : error C2440: 'initializing' : cannot convert from 'char' to 'char &'
D:\libraries\boost\boost/range/concepts.hpp(147) : while compiling class template member function 'boost::range_detail::SinglePassIteratorConcept<Iterator>::~SinglePassIteratorConcept(void)'
with
[
Iterator=std::istreambuf_iterator<char,std::char_traits<char>>
]
D:\libraries\boost\boost/concept/detail/has_constraints.hpp(42) : see reference to class template instantiation 'boost::range_detail::SinglePassIteratorConcept<Iterator>' being compiled
with
[
Iterator=std::istreambuf_iterator<char,std::char_traits<char>>
]
D:\libraries\boost\boost/concept/detail/msvc.hpp(58) : see reference to class template instantiation 'boost::concepts::not_satisfied<Model>' being compiled
with
[
Model=boost::range_detail::SinglePassIteratorConcept<std::istreambuf_iterator<char,std::char_traits<char>>>
]
test.cpp(10) : see reference to class template instantiation 'boost::concepts::require<Model>' being compiled
with
[
Model=boost::range_detail::SinglePassIteratorConcept<std::istreambuf_iterator<char,std::char_traits<char>>>
]
D:\libraries\boost\boost/range/concepts.hpp(160) : error C2440: 'initializing' : cannot convert from 'char' to 'char &'
В результате алгоритмы Boost.Range, такие как boost::copy
, не работают с istreambuf_iterator
.
Что здесь происходит?Что я могу сделать, чтобы исправить или обойти это?
EDIT : Непосредственной причиной ошибки, по-видимому, является то, что istreambuf_iterator
s reference_type
равно char&
, ноэто operator*
возвращает char
.Для правильно сформированного итератора не должно operator*
всегда возвращаться reference_type
?