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

Side by Side Diff: mojo/public/cpp/system/macros.h

Issue 828373008: Allow constructing {Interface,Struct}Ptr from nullptr (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
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_SYSTEM_MACROS_H_ 5 #ifndef MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_
6 #define MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_ 6 #define MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_
7 7
8 #include "mojo/public/c/system/macros.h" 8 #include "mojo/public/c/system/macros.h"
9 9
10 // Define a set of C++ specific macros. 10 // Define a set of C++ specific macros.
(...skipping 11 matching lines...) Expand all
22 namespace mojo { 22 namespace mojo {
23 template <typename T, size_t N> 23 template <typename T, size_t N>
24 char(&ArraySizeHelper(T(&array)[N]))[N]; 24 char(&ArraySizeHelper(T(&array)[N]))[N];
25 #if !defined(_MSC_VER) 25 #if !defined(_MSC_VER)
26 template <typename T, size_t N> 26 template <typename T, size_t N>
27 char(&ArraySizeHelper(const T(&array)[N]))[N]; 27 char(&ArraySizeHelper(const T(&array)[N]))[N];
28 #endif 28 #endif
29 } // namespace mojo 29 } // namespace mojo
30 #define MOJO_ARRAYSIZE(array) (sizeof(::mojo::ArraySizeHelper(array))) 30 #define MOJO_ARRAYSIZE(array) (sizeof(::mojo::ArraySizeHelper(array)))
31 31
32 // Used to make a type move-only in C++03. See Chromium's base/move.h for more 32 // Used to make a type move-only. See Chromium's base/move.h for more
33 // details. 33 // details. The MoveOnlyTypeForCPP03 typedef is for Chromium's base/callback to
34 #define MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \ 34 // tell that this type is move-only.
35 private: \ 35 #define MOJO_MOVE_ONLY_TYPE(type) \
36 struct rvalue_type { \ 36 private: \
37 explicit rvalue_type(type* object) : object(object) {} \ 37 type(type&); \
38 type* object; \ 38 void operator=(type&); \
39 }; \ 39 \
40 type(type&); \ 40 public: \
41 void operator=(type&); \ 41 type&& Pass() MOJO_WARN_UNUSED_RESULT { return static_cast<type&&>(*this); } \
42 \ 42 typedef void MoveOnlyTypeForCPP03; \
43 public: \ 43 \
44 operator rvalue_type() { return rvalue_type(this); } \
45 type Pass() { return type(rvalue_type(this)); } \
46 typedef void MoveOnlyTypeForCPP03; \
47 \
48 private: 44 private:
49 #endif // MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_ 45 #endif // MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698