search

Home  >  Q&A  >  body text

真在学习c++模板,在看轮子哥的cpplinq时的疑问


在这里,后面的成员函数都没有用到values,为什么不能删掉?

迷茫迷茫2882 days ago596

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 13:41:21

    Cannot be deleted.

    This is related to the mechanism of std::shared_ptr. Here, values ​​stores a reference to a vector, which will be released after storage_iterator destruction. Saving this reference ensures that as long as storage_iterator survives, the reference objects (values) bound to the iterator will also survive.

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 13:41:21

    Do you want to delete the initialization of values ​​in the constructor or delete the entire values ​​member?

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:41:21

    ..........After deleting it, what do you use this class for?

    reply
    0
  • Cancelreply