gpt4 book ai didi

c++ - 错误:“std::copy”之间的重载歧义

转载 作者:太空宇宙 更新时间:2023-11-04 14:19:38 26 4
gpt4 key购买 nike

我有如下代码:

#include<set>
#include<iterator>

std::set<std::string> s1;
std::set<std::string> s2;
std::set<std::string> myresult;

void some_func() {
std::set_difference(s1.begin(), s1.end(), s2.begin(), s2.end(),std::inserter(myresult,myresult.begin()));
}

这给我编译错误:

/export/SunStudio/SUNWspro/prod/include/CC/Cstd/./algorithm.cc", line 2161: Error: Overloading ambiguity between "std::copy<__rwstd::__rb_tree<std::string, std::string, __rwstd::__ident<std::string, std::string>, std::less<std::string>, std::allocator<std::string>>::const_iterator, std::insert_iterator<std::set<std::string>>>(__rwstd::__rb_tree<std::string, std::string, __rwstd::__ident<std::string, std::string>, std::less<std::string>, std::allocator<std::string>>::const_iterator, __rwstd::__rb_tree<std::string, std::string, __rwstd::__ident<std::string, std::string>, std::less<std::string>, std::allocator<std::string>>::const_iterator, std::insert_iterator<std::set<std::string>>)" and "copy<__rwstd::__rb_tree<std::string, std::string, __rwstd::__ident<std::string, std::string>, std::less<std::string>, std::allocator<std::string>>::const_iterator, std::insert_iterator<std::set<std::string>>>(__rwstd::__rb_tree<std::string, std::string, __rwstd::__ident<std::string, std::string>, std::less<std::string>, std::allocator<std::string>>::const_iterator, __rwstd::__rb_tree<std::string, std::string, __rwstd::__ident<std::string, std::string>, std::less<std::string>, std::allocator<std::string>>::const_iterator, std::insert_iterator<std::set<std::string>>)".

最佳答案

你忘了添加

#include<algorithm>

到您的代码。

关于c++ - 错误:“std::copy”之间的重载歧义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8635186/

26 4 0
文章推荐: c++ - 可以通过编程方式控制进入笔记本电脑的交流电源吗?
文章推荐: css -
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com