Skip to main content
gamedev.net
🔒 Locked

Smart pointers implementation

Started by The C modest god 2 replies 400+ views
Original Post
The C modest god
The C modest god
Are there smart pointers in the std library? I am trying to find an implementation of smart pointers in msdn to see how it is done. But I am unable to. Maybe there are no smart pointers in std? Perhaps COM objects are supposed to be smart pointers? because thats the results I get. But COM is not necesseraly CPP. Thanks in advance.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
ToohrVyk
ToohrVyk
There are no smart pointers in the SC++L, although there are almost-smart pointers, such as std::auto_ptr. In general, people use boost::shared_ptr as a good smart pointer.
Nitage
Nitage
The only smart pointer in the C++ standard library is std::auto_ptr.

It's only a scoped smart pointer, not a reference counted one.
snk_kid
snk_kid
Quote:
Original post by The C modest god
Are there smart pointers in the std library?


In the current standard std::auto_ptr which implements transfer-of-ownership semantics, it's mainly for writing exception safe code (using RAII idiom) and for scoped allocations.

There are a couple more in the last phase of review for standardization. It's the library technical report 1 (TR1) but there not in the standard yet so it's optional for compiler vendors to implement library TR1. There are two of them std::tr1::shared_ptr and std::tr1::weak_ptr, these are derived or originate from boost's smart pointers. Dinkumware (the guys who implement the standard libraries for Visual C++) have implemented TR1 but this does not come with VC++ 2k5 .NET out the box, you have to pay for it.

Quote:
Original post by The C modest god
I am trying to find an implementation of smart pointers in msdn to see how it is done.


Look at boost smart pointers.

Quote:
Original post by The C modest god
Perhaps COM objects are supposed to be smart pointers? because thats the results I get.


COM objects are not smart pointers, they are objects that maintain an embedded reference count for which smart pointer could use like boost::intrusive_ptr.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.