scoped_refptr: support opaque pointed-to classes via extern template
commit3d16d9f6566c5fc82eb23ab7b09217a59fb0957b
authormdempsky <mdempsky@chromium.org>
Thu, 9 Oct 2014 22:17:09 +0000 (9 15:17 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 9 Oct 2014 22:17:21 +0000 (9 22:17 +0000)
treec4e801f0c2083c2f49720e08fe248bcc791f2323
parent940c62c2aa3299f72d7195c77ae122a55dc78067
scoped_refptr: support opaque pointed-to classes via extern template

The C++ spec says the compiler may instantiate inline template
function definitions (e.g., member functions defined inline within a
templated class, even without an explicit "inline" keyword) even if
there's an "extern template class Foo<Bar>;" declaration.

In the case of scoped_refptr, if we merely have a forward declaration
for a class like "class Opaque;", then "extern template class
scoped_refptr<Opaque>;" will still cause compiler errors because of
scoped_refptr's inline member functions that try to call AddRef() and
Release().

To solve this, this CL introduces static helper methods that are
defined out-of-line to provide access to the AddRef() and Release()
methods.

BUG=414363

Review URL: https://codereview.chromium.org/623633002

Cr-Commit-Position: refs/heads/master@{#298991}
base/base.gyp
base/memory/ref_counted.h
base/memory/ref_counted_unittest.cc
base/test/BUILD.gn
base/test/opaque_ref_counted.cc [new file with mode: 0644]
base/test/opaque_ref_counted.h [new file with mode: 0644]