folly: ReadMostlySharedPtr fix for `getStdShared()` method
Summary: Fix this error: In file included from FooUtils.cpp:2: folly/experimental/ReadMostlySharedPtr.h:323:21: error: 'ptr_' is a private member of 'folly::detail::ReadMostlySharedPtrCore<Foo, folly::TLRefCount>' return impl_->ptr_; ^ ... in instantiation of member function 'folly::ReadMostlySharedPtr<Foo, folly::TLRefCount>::getStdShared' requested here: getSomeReadMostlySharedPtr().getStdShared(); ^ buck-out/dev/gen/folly/__default_headers__#default,headers/folly/experimental/ReadMostlySharedPtr.h:94:22: note: declared private here std::shared_ptr<T> ptr_; ^ 1 error generated. The added test case repro's the above error (and the changes to the class fixes it). Alternatives include just making `ReadMostlySharedPtr` a friend class of `ReadMostlySharedPtrCore`, but that seems uglier than this fix, which was to simply use the public `getShared` method which already exists. As luck would have it, I had tried that, and also found that a `const ReadMostlySharedPtr` would still give some trouble because `getStdShared` was not marked `const`. Fixed that too. (I assume if a copy of a const `shared_ptr` member / such a member of a `const` instance is permissible, then the method should be const as well. Plus it's const in the other `ReadMostlySharedPtr` class.) Reviewed By: djwatson Differential Revision: D4377690 fbshipit-source-id: 8e9e778ca991fd04b0eb1e5762795d871ce0ee8d
Showing
Please register or sign in to comment