범위 시퀀스에 적용해야하는 복잡한 알고리즘 목록을 작성하려고합니다. 다음 코드와 비슷한 구문을 사용하여 여러 알고리즘을 중첩시키고 싶습니다. 내 유일한 문제는 컴파일되지 않는다는 것입니다. 어떤 제안?부스트 범위 알고리즘 결합, 예. boost :: copy and boost :: remove_if
bool pred(double x);
double d[]={1,2,3,4};
std::vector<double> x(d,d+4);
std::vector<double> y;
boost::copy(x, std::back_inserter(y)); // OK
boost::copy(boost::remove_if(x,&pred), std::back_inserter(y)); // ERROR
이 구문이 작동하려면 내부 알고리즘에 대한 템플릿 매개 변수를 지정하지 않아도됩니다. 이것은 auto 키워드를 사용하여 단순화 할 수 있지만 코드를 이전 버전과 호환되도록 유지해야합니다.
이
는 오류 메시지의 조각입니다 :1>c:\dev\thirdparty\boost\boost-1.48.0-windows-vc90-x32-p64925\installed\include\boost-1_48\boost/range/iterator.hpp(63) : error C2039: 'type' : is not a member of 'boost::mpl::eval_if_c<C,F1,F2>'
1> with
1> [
1> C=true,
1> F1=boost::range_const_iterator<std::_Vector_iterator<double,std::allocator<double>>>,
1> F2=boost::range_mutable_iterator<const std::_Vector_iterator<double,std::allocator<double>>>
1> ]
1> c:\dev\thirdparty\boost\boost-1.48.0-windows-vc90-x32-p64925\installed\include\boost-1_48\boost/range/concepts.hpp(256) : see reference to class template instantiation 'boost::range_iterator<C>' being compiled
1> with
1> [
1> C=const std::_Vector_iterator<double,std::allocator<double>>
1> ]
1> c:\dev\thirdparty\boost\boost-1.48.0-windows-vc90-x32-p64925\installed\include\boost-1_48\boost/concept/detail/has_constraints.hpp(42) : see reference to class template instantiation 'boost::SinglePassRangeConcept<T>' being compiled
1> with
1> [
1> T=const std::_Vector_iterator<double,std::allocator<double>>
1> ]
1> c:\dev\thirdparty\boost\boost-1.48.0-windows-vc90-x32-p64925\installed\include\boost-1_48\boost/concept/detail/msvc.hpp(53) : see reference to class template instantiation 'boost::concepts::not_satisfied<Model>' being compiled
1> with
1> [
1> Model=boost::SinglePassRangeConcept<const std::_Vector_iterator<double,std::allocator<double>>>
1> ]
1> c:\dev\thirdparty\boost\boost-1.48.0-windows-vc90-x32-p64925\installed\include\boost-1_48\boost/range/algorithm/copy.hpp(33) : see reference to class template instantiation 'boost::concepts::require<Model>' being compiled
1> with
1> [
1> Model=boost::SinglePassRangeConcept<const std::_Vector_iterator<double,std::allocator<double>>>
1> ]
1> ..\..\..\..\..\source\yotta\libraries\snl\unittests\StackOverflow.cpp(7) : see reference to function template instantiation 'OutputIterator boost::range::copy<std::_Vector_iterator<_Ty,_Alloc>,std::back_insert_iterator<_Container>>(const SinglePassRange &,OutputIterator)' being compiled
1> with
....
이 범위는 참조로 전달해야합니까? 또는 범위에 대한 참조를 포함하는 클래스 일 수 있습니까? – Adrian
+1 "내 유일한 문제는 컴파일되지 않습니다."입니다. 'cout << the_answer_to_it_all();의 유일한 문제는 컴파일되지 않는다는 것입니다. –