Which std types are guaranteed to be empty/null after being used as arg in move constructor

后端 未结 2 1651
伪装坚强ぢ
伪装坚强ぢ 2020-12-16 22:13

I know shared_ptr, unique_ptr, weak_ptr are guaranteed to be empty after used as RVR argument in the constructor of the same type, but

2条回答
  •  感情败类
    2020-12-16 22:38

    Types leaving moved-from objects in "empty" state are smart pointers, locks ([thread.lock.unique.cons]/21, [thread.lock.shared.cons]/21), file streams ([filebuf.cons]/(4.2)), futures ([futures.unique_future]/(8.2), [futures.shared_future]/10), promises ([futures.promise]/6), packaged tasks ([futures.task]/7), threads ([thread.thread.constr]/10), …

    By contrast, templates leaving the moved-from objects with unspecified values are function ([func.wrap.func.con]/6), basic_regex ([re.regex.construct]/13), basic_string ([string.cons]/2), containers…

提交回复
热议问题