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

Side by Side Diff: mojo/public/cpp/bindings/struct_ptr.h

Issue 1558333002: Rectify our use of std::nullptr_t, inclusions of <stddef.h>/<cstddef>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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 | « mojo/public/cpp/bindings/interface_request.h ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_
7 7
8 #include <cstddef> 8 #include <cstddef>
9 #include <memory> 9 #include <memory>
10 #include <new> 10 #include <new>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 MOJO_MOVE_ONLY_TYPE(StructPtr); 99 MOJO_MOVE_ONLY_TYPE(StructPtr);
100 }; 100 };
101 101
102 // Designed to be used when Struct is small and copyable. Unions are always 102 // Designed to be used when Struct is small and copyable. Unions are always
103 // InlinedStructPtr in practice. 103 // InlinedStructPtr in practice.
104 template <typename Struct> 104 template <typename Struct>
105 class InlinedStructPtr { 105 class InlinedStructPtr {
106 public: 106 public:
107 InlinedStructPtr() : is_null_(true) {} 107 InlinedStructPtr() : is_null_(true) {}
108 InlinedStructPtr(decltype(nullptr)) : is_null_(true) {} 108 InlinedStructPtr(std::nullptr_t) : is_null_(true) {}
109 109
110 ~InlinedStructPtr() {} 110 ~InlinedStructPtr() {}
111 111
112 InlinedStructPtr& operator=(decltype(nullptr)) { 112 InlinedStructPtr& operator=(std::nullptr_t) {
113 reset(); 113 reset();
114 return *this; 114 return *this;
115 } 115 }
116 116
117 InlinedStructPtr(InlinedStructPtr&& other) : is_null_(true) { Take(&other); } 117 InlinedStructPtr(InlinedStructPtr&& other) : is_null_(true) { Take(&other); }
118 InlinedStructPtr& operator=(InlinedStructPtr&& other) { 118 InlinedStructPtr& operator=(InlinedStructPtr&& other) {
119 Take(&other); 119 Take(&other);
120 return *this; 120 return *this;
121 } 121 }
122 122
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 mutable Struct value_; 172 mutable Struct value_;
173 bool is_null_; 173 bool is_null_;
174 174
175 MOJO_MOVE_ONLY_TYPE(InlinedStructPtr); 175 MOJO_MOVE_ONLY_TYPE(InlinedStructPtr);
176 }; 176 };
177 177
178 } // namespace mojo 178 } // namespace mojo
179 179
180 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ 180 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/interface_request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698