1e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck/* 252244fff29042926e21fa897ef5ab11148e35299John Reck * Copyright (C) 2014 The Android Open Source Project 3e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * 4e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * Licensed under the Apache License, Version 2.0 (the "License"); 5e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * you may not use this file except in compliance with the License. 6e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * You may obtain a copy of the License at 7e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * 8e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * http://www.apache.org/licenses/LICENSE-2.0 9e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * 10e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * Unless required by applicable law or agreed to in writing, software 11e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * distributed under the License is distributed on an "AS IS" BASIS, 12e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * See the License for the specific language governing permissions and 14e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * limitations under the License. 15e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck */ 1652244fff29042926e21fa897ef5ab11148e35299John Reck#ifndef MACROS_H 1752244fff29042926e21fa897ef5ab11148e35299John Reck#define MACROS_H 18e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck 19922d3a7f6f8c1c05a996ee3e91e8cbadfff560c9Chris Craik#include <type_traits> 20922d3a7f6f8c1c05a996ee3e91e8cbadfff560c9Chris Craik 2152244fff29042926e21fa897ef5ab11148e35299John Reck#define PREVENT_COPY_AND_ASSIGN(Type) \ 2252244fff29042926e21fa897ef5ab11148e35299John Reck private: \ 2365fe5eeb19e2e15c8b1ee91e8a2dcf0c25e48ca6Chris Craik Type(const Type&) = delete; \ 2465fe5eeb19e2e15c8b1ee91e8a2dcf0c25e48ca6Chris Craik void operator=(const Type&) = delete 25e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck 267224e2b624daea67b5653285c9640f170c096bdbsergeyv#define HASHABLE_TYPE(Type) \ 277224e2b624daea67b5653285c9640f170c096bdbsergeyv bool operator==(const Type& other) const; \ 287224e2b624daea67b5653285c9640f170c096bdbsergeyv hash_t hash() const; \ 297224e2b624daea67b5653285c9640f170c096bdbsergeyv bool operator!=(const Type& other) const { return !(*this == other); } \ 3005f3d6e5111fd08df5cd9aae2c3d28399dc0e7f5Chris Craik friend inline hash_t hash_type(const Type& entry) { return entry.hash(); } 31496b8770c19c573299e4be525e877acc977a2dadJohn Reck 320519c810a56bded1284fcb2ae40f438878c6585fChris Craik#define REQUIRE_COMPATIBLE_LAYOUT(Type) \ 330519c810a56bded1284fcb2ae40f438878c6585fChris Craik static_assert(std::is_standard_layout<Type>::value, \ 340519c810a56bded1284fcb2ae40f438878c6585fChris Craik #Type " must have standard layout") 350519c810a56bded1284fcb2ae40f438878c6585fChris Craik 369fded232a9548a304e0145011df8849fba0dcda7Chris Craik#define WARN_UNUSED_RESULT \ 379fded232a9548a304e0145011df8849fba0dcda7Chris Craik __attribute__((warn_unused_result)) 389fded232a9548a304e0145011df8849fba0dcda7Chris Craik 3952244fff29042926e21fa897ef5ab11148e35299John Reck#endif /* MACROS_H */ 40