1

我在 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中的向量应该有插入,我错过了什么吗?

running_jobs = vector<boost::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool> > running_jobs;

 line 223    running_jobs.insert(running, wait.end());
4

2 回答 2

3

问题确实是您对insert. 看看
http://www.cplusplus.com/reference/stl/vector/insert/

您必须告诉insert插入的位置running_jobs。可能是这样的:

running_jobs.insert(running_jobs.end(), running, wait.end());
于 2012-07-23T12:29:29.347 回答
1

什么是 running_jobs?我认为它是一个向量。还有对象“等待”我假设它是一个向量

通话

running_jobs.insert(running, wait.end());

是错的。第一个参数必须是迭代器,所以正确的调用应该是

running_jobs.insert( wait.end(), running);

希望这有效

于 2012-07-23T12:24:45.000 回答