Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: base/memory/scoped_ptr_unittest.nc

Issue 9958150: Make sure that scoped_ptr<> cannot be used with ref-counted objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/memory/scoped_ptr.h ('k') | chrome/common/service_process_util_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/ref_counted.h"
7 8
8 namespace { 9 namespace {
9 10
10 class Parent { 11 class Parent {
11 }; 12 };
12 13
13 class Child : public Parent { 14 class Child : public Parent {
14 }; 15 };
15 16
17 class RefCountedClass : public base::RefCountedThreadSafe<RefCountedClass> {
18 };
19
16 } // namespace 20 } // namespace
17 21
18 #if defined(NCTEST_NO_PASSAS_DOWNCAST) // [r"invalid conversion from"] 22 #if defined(NCTEST_NO_PASSAS_DOWNCAST) // [r"invalid conversion from"]
19 23
20 scoped_ptr<Child> DowncastUsingPassAs(scoped_ptr<Parent> object) { 24 scoped_ptr<Child> DowncastUsingPassAs(scoped_ptr<Parent> object) {
21 return object.PassAs<Child>(); 25 return object.PassAs<Child>();
22 } 26 }
23 27
28 #elif defined(NCTEST_NO_REF_COUNTED_SCOPED_PTR) // [r"creating array with negat ive size"]
brettw 2012/04/04 21:31:06 Is it possible to wrap this somehow to 80 cols? I
Sergey Ulanov 2012/04/04 22:28:38 Don't think it is possible right now - all other n
29
30 // scoped_ptr<> should not work for ref-counted objects.
31 void WontCompile() {
32 scoped_ptr<RefCountedClass> x;
33 }
34
24 #endif 35 #endif
OLDNEW
« no previous file with comments | « base/memory/scoped_ptr.h ('k') | chrome/common/service_process_util_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698