Use of observer_ptr

前端 未结 7 1332
自闭症患者
自闭症患者 2020-12-09 01:15

What exactly is the point of the construct std::observer_ptr in the library fundamentals technical specification V2?

It seems to me that all it does is wrap a bare <

7条回答
  •  被撕碎了的回忆
    2020-12-09 01:30

    The proposal makes it pretty clear that it's just for self-documentation:

    This paper proposes observer_ptr, a (not very) smart pointer type that takes no ownership responsibility for its pointees, i.e., for the objects it observes. As such, it is intended as a near drop-in replacement for raw pointer types, with the advantage that, as a vocabulary type, it indicates its intended use without need for detailed analysis by code readers.

提交回复
热议问题