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 // This file contains macros and macro-like constructs (e.g., templates) that 6 // are commonly used throughout Chromium source. (It may also contain things 7 // that are closely related to things that are commonly used that belong in this 8 // file.) 9 10 #ifndef BASE_MACROS_H_ 11 #define BASE_MACROS_H_ 12 13 // Distinguish mips32. 14 #if defined(__mips__) && (_MIPS_SIM == _ABIO32) && !defined(__mips32__) 15 #define __mips32__ 16 #endif 17 18 // Distinguish mips64. 19 #if defined(__mips__) && (_MIPS_SIM == _ABI64) && !defined(__mips64__) 20 #define __mips64__ 21 #endif 22 23 // Put this in the declarations for a class to be uncopyable. 24 #define DISALLOW_COPY(TypeName) TypeName(const TypeName&) = delete 25 26 // Put this in the declarations for a class to be unassignable. 27 #define DISALLOW_ASSIGN(TypeName) TypeName& operator=(const TypeName&) = delete 28 29 // Put this in the declarations for a class to be uncopyable and unassignable. 30 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ 31 DISALLOW_COPY(TypeName); \ 32 DISALLOW_ASSIGN(TypeName) 33 34 // A macro to disallow all the implicit constructors, namely the 35 // default constructor, copy constructor and operator= functions. 36 // This is especially useful for classes containing only static methods. 37 #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ 38 TypeName() = delete; \ 39 DISALLOW_COPY_AND_ASSIGN(TypeName) 40 41 // Used to explicitly mark the return value of a function as unused. If you are 42 // really sure you don't want to do anything with the return value of a function 43 // that has been marked WARN_UNUSED_RESULT, wrap it with this. Example: 44 // 45 // std::unique_ptr<MyType> my_var = ...; 46 // if (TakeOwnership(my_var.get()) == SUCCESS) 47 // ignore_result(my_var.release()); 48 // 49 template <typename T> ignore_result(const T &)50inline void ignore_result(const T&) {} 51 52 #endif // BASE_MACROS_H_ 53