다음 프로그램 :왜 std :: istreambuf_iterator가 부스트의 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 모두 컴파일에 실패.
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::copy
같은 Boost.Range에게 알고리즘 istreambuf_iterator
작동하지 않습니다 다음과 같이 MSVC 오류입니다.
여기에 무슨 일이 일어나고 있습니까? 문제를 해결하거나 해결하려면 어떻게해야합니까?
편집 : 오류의 근인은 istreambuf_iterator
의 reference_type
이 char&
인 것 같다,하지만 operator*
반환 char
입니다. 잘 구성된 반복자의 경우 operator*
은 항상 reference_type
을 반환하지 않아야합니다.
idk하지만 좋은 캐치 인 것 같습니다! :-) 아마도 메일 링리스트를 부탁 할 것입니다. –