STL class for reference-counted pointers?

前端 未结 5 2035
花落未央
花落未央 2021-02-13 23:23

This should be trivial but I can\'t seem to find it (unless no such class exists!)

What\'s the STL class (or set of classes) for smart pointers?

UPDATE

5条回答
  •  遥遥无期
    2021-02-14 00:11

    With the exception of the already mentionned TR1 shared_ptr, there is no reference-counted pointer in STL.

    I suggest you use boost::shared_ptr (downloading boost will be enough, there is nothing to compile, its implementation is header-only).

    You may also want to have a look at smart pointers from Loki libraries (again, header-only implementation).

    For an overview of available smart pointers, see there.

提交回复
热议问题