Namespaces
Variants
Views
Actions

Talk:cpp/memory/shared ptr

From cppreference.com

For some reason, in the "Implementation Notes" section, the link to "allocate_shared" links to "http://en.cppreference.com/w/cpp/memory/shared_ptr/allocate_sharod", both on hover, copy, and click. Looking at the markup, the referred-to page-name looks correctly spelt... I don't get it. Manually going to http://en.cppreference.com/w/cpp/memory/shared_ptr/allocate_shared works.

It's a typo in MediaWiki:Simple-search-list and MediaWiki:Geshi-keyword-list-cpp, User:P12 can fix that. --Cubbi 11:45, 6 June 2012 (PDT)
Fixed. Thanks. -- P12 13:01, 6 June 2012 (PDT)

[edit] missing operator->*

Is there a reason why shared_ptr does not overload operator->*? That operator would ease the access of the pointee's member via "pointer to member":

I'd like to access them via shp->*member but that does not work, and I have to write (*shp).*member which looks awkward and unnaturally to me. --31.18.70.70 06:37, 15 December 2014 (PST)

You could also write shp.get()->*member or (&*shp)->*member if you want the correct operator to be called. Some early smart pointers overloaded ->*, but the boost implementation of shared_ptr, on which C++ is based, didn't. I see it was recently brought up on stackoverflow with no conclusive answer. --Cubbi (talk) 06:50, 15 December 2014 (PST)