0

请帮助我解决这个错误并......(visual studio 2010)

void file_remove(u32 id, int action) {
    file f;
    f.id = id;

    **file_set::iterator i = fs.find(f);**

    if(i == fs.end()) return;

    // move cursor away
    if(conf.expose.cursor == id) cursor_down();
    if(conf.expose.cursor == id) cursor_up();
    if(conf.expose.cursor == id) conf.expose.cursor = 0;


    if(action != 1 && i->size >= conf.files.incomp_min_size &&
        (u64)segment_summ(i->seg) * 100 / i->size >= conf.files.incomp_percent)
    {   action = 2;     }

    char n1[0x100];
    char n2[0x100];


    if(!i->deleted){
        cache_close(i->h);

        snprintf(n1, sizeof(n1), "%s/%s", conf.fnames.dir_temp, i->name.c_str());

        if(action == 0)
        {   // just close
        }
        else if(action == 1)
        {
            snprintf(n2, sizeof(n2), "%s/%s", conf.fnames.dir_ok, i->name.c_str());         seg(*i, conf.fnames.dir_temp, false);
        cache_move(n1, n2);
        }
        else if(action == 2)
        {
            snprintf(n2, sizeof(n2), "%s/%s", conf.fnames.dir_incomplete, i->name.c_str());
        seg(*i, conf.fnames.dir_incomplete, true, true);
        seg(*i, conf.fnames.dir_temp, false);
        cache_move(n1, n2);
        }
        else if(action == -1)
        {
            seg(*i, conf.fnames.dir_temp, false);
        cache_move(n1, ""); // unlink
        }
    } else {
        ffs_remove(i->size, i->tag);
        fs.erase(i);
        sort_files();
        return;
    }

    if(!i->tmp){
        ffs_remove(i->size, i->tag);
        fs.erase(i);
    } else {
        **i->deleted = true;**
    }
    sort_files();
}

用这个元素编译它并出错:i->deleted = true; + 查看此结果

1>main.cpp(478): error C3892: 'std::_Tree_unchecked_const_iterator<_Mytree,_Base>::operator ->' : 你不能用 1>
[ 1>
_Mytree=std 赋值给 const 1> 的变量: :_Tree_val,std::allocator,false>>, 1> _Base=std::_Iterator_base 1> ]

http://up.vbiran.ir/images/w21nnbxc7tf5okzk0lr.png

http://up.vbiran.ir/images/x0coajrixr764g49ibeh.png

请帮我解决这个错误

4

1 回答 1

1

是的,这就是问题所在

i->deleted = true; 

在 astd::set所有元素都是 const (因为更改值可能会使集合的顺序无效)。

于 2012-07-21T11:33:13.023 回答