2
下面的程序:爲什麼std :: istreambuf_iterator失敗boost的SinglePassIterator概念檢查?
#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
工作。
這是怎麼回事?我能做些什麼來解決或解決它?
編輯:錯誤的直接原因似乎是,istreambuf_iterator
的reference_type
是char&
,但它的回報operator*
char
。對於格式良好的迭代器,不應該總是返回?
idk,但它似乎是一個很好的抓住! :-)也許在boost郵件列表上提問。 –