我的源代码非常简单:
#include <set>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
using namespace std;
void test() {
set<string> *S = new set<string>;
S->insert("hi");
S->insert("lo");
set<string> *T = new set<string>;
T->insert("lo");
set<string> *s = new set<string>;
set<string>::iterator l=s->begin();
set_difference(S->begin(),S->end(),T->begin(),T->end(),l);
}
Run Code Online (Sandbox Code Playgroud)
那么为什么我会收到编译器错误:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(4671): error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const std::basic_string<_Elem,_Traits,_Ax>'
Run Code Online (Sandbox Code Playgroud)
集合"s"只是一组字符串,没有任何常量.