I'm trying to use STL function transform to transform all the strings in a set to lowcase. But I got an error of C2664. I wonder what the wrong with my code?
set<string> mydoc;
mydoc.insert("ABCD");
transform(mydoc.begin(), mydoc.end(), mydoc.begin(), ::tolower);
copy(mydoc.begin(), mydoc.end(), output);
std::stringtotolower.setiterator isconst.Thus, you should probably apply
tolowerto eachstringwhen inserting it into thesetinstead of changing it afterwards because you'd have to waste time by reinserting every element into a sorted container.