| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_ | |
| 6 #define MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_ | |
| 7 | |
| 8 #include "mojo/public/c/system/macros.h" | |
| 9 | |
| 10 // Define a set of C++ specific macros. | |
| 11 // Mojo C++ API users can assume that mojo/public/cpp/system/macros.h | |
| 12 // includes mojo/public/c/system/macros.h. | |
| 13 | |
| 14 // A macro to disallow the copy constructor and operator= functions. | |
| 15 // This should be used in the private: declarations for a class. | |
| 16 #define MOJO_DISALLOW_COPY_AND_ASSIGN(TypeName) \ | |
| 17 TypeName(const TypeName&); \ | |
| 18 void operator=(const TypeName&) | |
| 19 | |
| 20 // Used to calculate the number of elements in an array. | |
| 21 // (See |arraysize()| in Chromium's base/basictypes.h for more details.) | |
| 22 namespace mojo { | |
| 23 template <typename T, size_t N> | |
| 24 char(&ArraySizeHelper(T(&array)[N]))[N]; | |
| 25 #if !defined(_MSC_VER) | |
| 26 template <typename T, size_t N> | |
| 27 char(&ArraySizeHelper(const T(&array)[N]))[N]; | |
| 28 #endif | |
| 29 } // namespace mojo | |
| 30 #define MOJO_ARRAYSIZE(array) (sizeof(::mojo::ArraySizeHelper(array))) | |
| 31 | |
| 32 // Used to make a type move-only. See Chromium's base/move.h for more | |
| 33 // details. The MoveOnlyTypeForCPP03 typedef is for Chromium's base/callback to | |
| 34 // tell that this type is move-only. | |
| 35 #define MOJO_MOVE_ONLY_TYPE(type) \ | |
| 36 private: \ | |
| 37 type(type&); \ | |
| 38 void operator=(type&); \ | |
| 39 \ | |
| 40 public: \ | |
| 41 type&& Pass() MOJO_WARN_UNUSED_RESULT { return static_cast<type&&>(*this); } \ | |
| 42 typedef void MoveOnlyTypeForCPP03; \ | |
| 43 \ | |
| 44 private: | |
| 45 #endif // MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_ | |
| OLD | NEW |