1e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// Copyright 2014 The Chromium Authors. All rights reserved. 2e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// Use of this source code is governed by a BSD-style license that can be 3e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// found in the LICENSE file. 4e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 5e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// This file contains macros and macro-like constructs (e.g., templates) that 6e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// are commonly used throughout Chromium source. (It may also contain things 7e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// that are closely related to things that are commonly used that belong in this 8e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// file.) 9e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 10e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov#ifndef PDFIUM_THIRD_PARTY_BASE_MACROS_H_ 11e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov#define PDFIUM_THIRD_PARTY_BASE_MACROS_H_ 12e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 13e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// The COMPILE_ASSERT macro can be used to verify that a compile time 14e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// expression is true. For example, you could use it to verify the 15e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// size of a static array: 16e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// 17e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES, 18e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// content_type_names_incorrect_size); 19e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// 20e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// or to make sure a struct is smaller than a certain size: 21e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// 22e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); 23e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// 24e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// The second argument to the macro is the name of the variable. If 25e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// the expression is false, most compilers will issue a warning/error 26e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// containing the name of the variable. 27e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 28e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov#undef COMPILE_ASSERT 29e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg) 30e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 31d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann// A macro to disallow the copy constructor and operator= functions. 32d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann// This should be used in the private: declarations for a class. 33d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ 34d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann TypeName(const TypeName&) = delete; \ 35d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void operator=(const TypeName&) = delete 36d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann 37e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov#endif // PDFIUM_THIRD_PARTY_BASE_MACROS_H_ 38