1

私は以下のようなコードを持っています:

#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"、2161 行目: エラー: "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>>)" および "copy<__rwstd:: __rb_tree<std::文字列、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>>)".(__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>>)".(__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>>)".
4

1 に答える 1

0

追加するのを忘れた

#include<algorithm>

あなたのコードに。

于 2012-01-10T12:44:41.003 に答える