1
我有象下面這樣的代碼:錯誤:STD之間的」重載歧義::複製
#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>>)".
添加類型 – Vijay 2011-12-26 11:19:47
這必須是特定於SunStudio的:我在Mac上用C++編譯器編譯了代碼,並且它沒有編譯任何警告。 – dasblinkenlight 2011-12-26 11:24:50
經典ADL/Koenig查找問題的這種氣味。 – 2011-12-26 11:26:04