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

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

Issue 1556683003: Fix no-compile base_unittests for base::Pass() -> std::move conversion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unneeded std::move Created 4 years, 11 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
« no previous file with comments | « base/callback_list_unittest.nc ('k') | no next file » | 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 // This is a "No Compile Test" suite. 5 // This is a "No Compile Test" suite.
6 // http://dev.chromium.org/developers/testing/no-compile-tests 6 // http://dev.chromium.org/developers/testing/no-compile-tests
7 7
8 #include "base/memory/scoped_ptr.h"
9
10 #include <utility>
11
8 #include "base/macros.h" 12 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
11 14
12 namespace { 15 namespace {
13 16
14 class Parent { 17 class Parent {
15 }; 18 };
16 19
17 class Child : public Parent { 20 class Child : public Parent {
18 }; 21 };
19 22
20 class RefCountedClass : public base::RefCountedThreadSafe<RefCountedClass> { 23 class RefCountedClass : public base::RefCountedThreadSafe<RefCountedClass> {
21 }; 24 };
22 25
23 } // namespace 26 } // namespace
24 27
25 #if defined(NCTEST_NO_PASS_DOWNCAST) // [r"fatal error: no viable conversion fr om returned value of type 'scoped_ptr<\(anonymous namespace\)::Parent, default_d elete<\(anonymous namespace\)::Parent>>' to function return type 'scoped_ptr<\(a nonymous namespace\)::Child, default_delete<\(anonymous namespace\)::Child>>'"] 28 #if defined(NCTEST_NO_PASS_DOWNCAST) // [r"fatal error: no viable conversion fr om returned value of type 'scoped_ptr<\(anonymous namespace\)::Parent, default_d elete<\(anonymous namespace\)::Parent>>' to function return type 'scoped_ptr<\(a nonymous namespace\)::Child, default_delete<\(anonymous namespace\)::Child>>'"]
26 29
27 scoped_ptr<Child> DowncastUsingPassAs(scoped_ptr<Parent> object) { 30 scoped_ptr<Child> DowncastUsingPassAs(scoped_ptr<Parent> object) {
28 return object.Pass(); 31 return object;
29 } 32 }
30 33
31 #elif defined(NCTEST_NO_REF_COUNTED_SCOPED_PTR) // [r"fatal error: static_asser t failed \"T is a refcounted type and needs a scoped_refptr\""] 34 #elif defined(NCTEST_NO_REF_COUNTED_SCOPED_PTR) // [r"fatal error: static_asser t failed \"T is a refcounted type and needs a scoped_refptr\""]
32 35
33 // scoped_ptr<> should not work for ref-counted objects. 36 // scoped_ptr<> should not work for ref-counted objects.
34 void WontCompile() { 37 void WontCompile() {
35 scoped_ptr<RefCountedClass> x; 38 scoped_ptr<RefCountedClass> x;
36 } 39 }
37 40
38 #elif defined(NCTEST_NO_ARRAY_WITH_SIZE) // [r"fatal error: static_assert faile d \"scoped_ptr doesn't support array with size\""] 41 #elif defined(NCTEST_NO_ARRAY_WITH_SIZE) // [r"fatal error: static_assert faile d \"scoped_ptr doesn't support array with size\""]
39 42
40 void WontCompile() { 43 void WontCompile() {
41 scoped_ptr<int[10]> x; 44 scoped_ptr<int[10]> x;
42 } 45 }
43 46
44 #elif defined(NCTEST_NO_PASS_FROM_ARRAY) // [r"fatal error: no viable overloade d '='"] 47 #elif defined(NCTEST_NO_PASS_FROM_ARRAY) // [r"fatal error: no viable overloade d '='"]
45 48
46 void WontCompile() { 49 void WontCompile() {
47 scoped_ptr<int[]> a; 50 scoped_ptr<int[]> a;
48 scoped_ptr<int*> b; 51 scoped_ptr<int*> b;
49 b = a.Pass(); 52 b = std::move(a);
50 } 53 }
51 54
52 #elif defined(NCTEST_NO_PASS_TO_ARRAY) // [r"fatal error: no viable overloaded '='"] 55 #elif defined(NCTEST_NO_PASS_TO_ARRAY) // [r"fatal error: no viable overloaded '='"]
53 56
54 void WontCompile() { 57 void WontCompile() {
55 scoped_ptr<int*> a; 58 scoped_ptr<int*> a;
56 scoped_ptr<int[]> b; 59 scoped_ptr<int[]> b;
57 b = a.Pass(); 60 b = std::move(a);
58 } 61 }
59 62
60 #elif defined(NCTEST_NO_CONSTRUCT_FROM_ARRAY) // [r"fatal error: no matching co nstructor for initialization of 'scoped_ptr<int \*>'"] 63 #elif defined(NCTEST_NO_CONSTRUCT_FROM_ARRAY) // [r"fatal error: no matching co nstructor for initialization of 'scoped_ptr<int \*>'"]
61 64
62 void WontCompile() { 65 void WontCompile() {
63 scoped_ptr<int[]> a; 66 scoped_ptr<int[]> a;
64 scoped_ptr<int*> b(a.Pass()); 67 scoped_ptr<int*> b(std::move(a));
65 } 68 }
66 69
67 #elif defined(NCTEST_NO_CONSTRUCT_TO_ARRAY) // [r"fatal error: no matching cons tructor for initialization of 'scoped_ptr<int \[\]>'"] 70 #elif defined(NCTEST_NO_CONSTRUCT_TO_ARRAY) // [r"fatal error: no matching cons tructor for initialization of 'scoped_ptr<int \[\]>'"]
68 71
69 void WontCompile() { 72 void WontCompile() {
70 scoped_ptr<int*> a; 73 scoped_ptr<int*> a;
71 scoped_ptr<int[]> b(a.Pass()); 74 scoped_ptr<int[]> b(std::move(a));
72 } 75 }
73 76
74 #elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_NULL) // [r"is ambiguou s"] 77 #elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_NULL) // [r"is ambiguou s"]
75 78
76 void WontCompile() { 79 void WontCompile() {
77 scoped_ptr<int[]> x(NULL); 80 scoped_ptr<int[]> x(NULL);
78 } 81 }
79 82
80 #elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_DERIVED) // [r"fatal er ror: calling a private constructor of class 'scoped_ptr<\(anonymous namespace\): :Parent \[\], std::default_delete<\(anonymous namespace\)::Parent \[\]> >'"] 83 #elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_DERIVED) // [r"fatal er ror: calling a private constructor of class 'scoped_ptr<\(anonymous namespace\): :Parent \[\], std::default_delete<\(anonymous namespace\)::Parent \[\]> >'"]
81 84
(...skipping 25 matching lines...) Expand all
107 // support would require changes to the behavior of the constructors to match 110 // support would require changes to the behavior of the constructors to match
108 // including the use of SFINAE to discard the type-converting constructor 111 // including the use of SFINAE to discard the type-converting constructor
109 // as per C++11 20.7.1.2.1.19. 112 // as per C++11 20.7.1.2.1.19.
110 void WontCompile() { 113 void WontCompile() {
111 Deleter d; 114 Deleter d;
112 int n; 115 int n;
113 scoped_ptr<int*, Deleter&> a(&n, d); 116 scoped_ptr<int*, Deleter&> a(&n, d);
114 } 117 }
115 118
116 #endif 119 #endif
OLDNEW
« no previous file with comments | « base/callback_list_unittest.nc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698