我在c ++中有一个矢量代码:
typedef vector<boost::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool> >::iterator traveling;
traveling running =
std::partition( wait.begin(), wait.end(), tuple_comp );
running_jobs.insert(running, wait.end());
wait.erase( running, wait.end() );
这个错误给了我:
main.cpp:223: error: no matching function for call to ‘std::vector<boost::tuples::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, std::allocator<boost::tuples::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >
>::insert(threaded_function(ppa::Model_factory&, ppa::Node*)::traveling&,
__gnu_cxx::__normal_iterator<boost::tuples::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>*, std::vector<boost::tuples::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, std::allocator<boost::tuples::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > > >)’
这是netbeans 7.2,我不知道std中的vector应该有插入,我错过了什么?
running_jobs = vector<boost::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool> > running_jobs;
line 223 running_jobs.insert(running, wait.end());
答案 0 :(得分:3)
问题确实是你对insert
的呼唤。看看
http://www.cplusplus.com/reference/stl/vector/insert/
您必须告诉insert
将running_jobs
插入的位置。可能是这样的:
running_jobs.insert(running_jobs.end(), running, wait.end());
答案 1 :(得分:1)
什么是running_jobs?我把它作为一个向量。对象&#34;等待&#34;我假设它是一个向量
用于通话
running_jobs.insert(running, wait.end());
错了。第一个参数必须是迭代器 所以正确的电话应该是
running_jobs.insert( wait.end(), running);
希望这有效