gpt4 book ai didi

c++ - std::vector 插入错误

转载 作者:行者123 更新时间:2023-11-30 02:03:38 25 4
gpt4 key购买 nike

我有一个用 C++ 编写的 vector 代码:

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());

最佳答案

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

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

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

关于c++ - std::vector 插入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11612330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com