【发布时间】:2012-12-27 23:32:25
【问题描述】:
可能重复:
C++ STL set update is tedious: I can’t change an element in place
我被难住了:
struct File {
struct Handle {
size_t count;
};
std::set<Handle>::iterator handle_;
~File() {
File::close(*this);
}
static void close(File &f) {
(*f.handle_).count--;
}
};
对于 ICC,错误是:
error #137: expression must be a modifiable lvalue
(*f.handle_).count++;
^
为什么 std::set::iterator 是常量?
【问题讨论】:
-
@jrok 哦……我现在明白了。无赖
标签: c++