2016-12-04 109 views
-2

我试图使用STL函数transform将集合中的所有字符串转换为小写。但是我得到了C2664的错误。我不知道我的代码有什么问题?在集合转换为小写C++ errorC2664

set<string> mydoc; 
mydoc.insert("ABCD"); 
transform(mydoc.begin(), mydoc.end(), mydoc.begin(), ::tolower); 
copy(mydoc.begin(), mydoc.end(), output); 
+0

不是[标签信息](http://stackoverflow.com/tags/c2664/info)解释得不错吗? –

+0

1.“集合”中每个迭代器的类型是指什么(存储在集合中)? 2.“tolower”所期望的类型是什么? – Pixelchemist

+0

@Pixelchemist'ostream_iterator output(cout,“\ n”);'是迭代器 –

回答

0
  1. 你不能传递到std::stringtolower
  2. C++ 11 set迭代器是const

因此,插入它时,到set,而不是事后改变它,因为你必须通过每一个元素重新插入排序容器浪费时间你应该申请tolower每个string