folly: ReadMostlySharedPtr fix for `getStdShared()` method
authorSteve O'Brien <steveo@fb.com>
Tue, 3 Jan 2017 21:45:15 +0000 (13:45 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 3 Jan 2017 21:48:09 +0000 (13:48 -0800)
commit38894440d462e055099699723c26cb8551c1e4a3
tree815fa8117ace454d646f5879b40a8afb4ba0380b
parent03a4c5bd8fc60ce0bed9531fcd88b06c06cb27cc
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
folly/experimental/ReadMostlySharedPtr.h
folly/experimental/test/ReadMostlySharedPtrTest.cpp