summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-13 15:46:34 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-13 15:46:34 +0000
commitc074a54a4f5256cc33c6556c68b0c2a3b989e250 (patch)
tree33921c2b773b5846caeb4dc760189badb881343f
parent1905017541f97483b6efbbc81b6d03775603aecf (diff)
downloadchromium_src-c074a54a4f5256cc33c6556c68b0c2a3b989e250.zip
chromium_src-c074a54a4f5256cc33c6556c68b0c2a3b989e250.tar.gz
chromium_src-c074a54a4f5256cc33c6556c68b0c2a3b989e250.tar.bz2
Remove the explicit keyword from the ScopedComPtr constructor so it can be included in a STL container.
Review URL: http://codereview.chromium.org/115247 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15958 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/scoped_comptr_win.h2
-rw-r--r--base/scoped_comptr_win_unittest.cc45
2 files changed, 46 insertions, 1 deletions
diff --git a/base/scoped_comptr_win.h b/base/scoped_comptr_win.h
index 9ba0b84..3fa419f 100644
--- a/base/scoped_comptr_win.h
+++ b/base/scoped_comptr_win.h
@@ -34,7 +34,7 @@ class ScopedComPtr : public scoped_refptr<Interface> {
explicit ScopedComPtr(Interface* p) : ParentClass(p) {
}
- explicit ScopedComPtr(const ScopedComPtr<Interface, interface_id>& p)
+ ScopedComPtr(const ScopedComPtr<Interface, interface_id>& p)
: ParentClass(p) {
}
diff --git a/base/scoped_comptr_win_unittest.cc b/base/scoped_comptr_win_unittest.cc
index 5e4ad3d..e6d6c68 100644
--- a/base/scoped_comptr_win_unittest.cc
+++ b/base/scoped_comptr_win_unittest.cc
@@ -5,8 +5,26 @@
#include <shlobj.h>
#include "base/scoped_comptr_win.h"
+#include "base/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace {
+
+struct Dummy {
+ Dummy() : adds(0), releases(0) { }
+ void AddRef() { ++adds; }
+ void Release() { ++releases; }
+
+ int adds;
+ int releases;
+};
+
+extern const IID dummy_iid;
+const IID dummy_iid = { 0x12345678u, 0x1234u, 0x5678u, 01, 23, 45, 67, 89,
+ 01, 23, 45 };
+
+} // namespace
+
TEST(ScopedComPtrTest, ScopedComPtr) {
EXPECT_TRUE(memcmp(&ScopedComPtr<IUnknown>::iid(), &IID_IUnknown,
sizeof(IID)) == 0);
@@ -50,3 +68,30 @@ TEST(ScopedComPtrTest, ScopedComPtr) {
::CoUninitialize();
}
+
+TEST(ScopedComPtrTest, ScopedComPtrVector) {
+ // Verify we don't get error C2558.
+ typedef ScopedComPtr<Dummy, &dummy_iid> Ptr;
+ std::vector<Ptr> bleh;
+ scoped_ptr<Dummy> p(new Dummy);
+ {
+ Ptr p2(p.get());
+ EXPECT_EQ(p->adds, 1);
+ EXPECT_EQ(p->releases, 0);
+ Ptr p3 = p2;
+ EXPECT_EQ(p->adds, 2);
+ EXPECT_EQ(p->releases, 0);
+ p3 = p2;
+ EXPECT_EQ(p->adds, 3);
+ EXPECT_EQ(p->releases, 1);
+ bleh.push_back(p2);
+ EXPECT_EQ(p->adds, 5);
+ EXPECT_EQ(p->releases, 2);
+ EXPECT_EQ(bleh[0], p.get());
+ bleh.pop_back();
+ EXPECT_EQ(p->adds, 5);
+ EXPECT_EQ(p->releases, 3);
+ }
+ EXPECT_EQ(p->adds, 5);
+ EXPECT_EQ(p->releases, 5);
+}