| OLD | NEW |
| 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 Loading... |
| 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_ |
| OLD | NEW |