macros.h
Go to the documentation of this file.
1 /*
2 * ECVL - European Computer Vision Library
3 * Version: 0.3.4
4 * copyright (c) 2021, Università degli Studi di Modena e Reggio Emilia (UNIMORE), AImageLab
5 * Authors:
6 * Costantino Grana (costantino.grana@unimore.it)
7 * Federico Bolelli (federico.bolelli@unimore.it)
8 * Michele Cancilla (michele.cancilla@unimore.it)
9 * Laura Canalini (laura.canalini@unimore.it)
10 * Stefano Allegretti (stefano.allegretti@unimore.it)
11 * All rights reserved.
12 */
13 
14 #ifndef ECVL_MACROS_H_
15 #define ECVL_MACROS_H_
16 
20 #define DEFINE_ENUM_CLASS_OR_OPERATOR(class_name) \
21 constexpr enum class_name operator|(const enum class_name self_value, const enum class_name in_value) { \
22  return static_cast<enum class_name>(static_cast<uint32_t>(self_value) | static_cast<uint32_t>(in_value)); \
23 } \
24 
25 
28 #define DEFINE_ENUM_CLASS_AND_OPERATOR(class_name) \
29 constexpr bool operator&(const enum class_name self_value, const enum class_name in_value) { \
30  return static_cast<bool>(static_cast<uint32_t>(self_value) & static_cast<uint32_t>(in_value)); \
31 } \
32 
33 #define DEFINE_ENUM_CLASS_FLAGS(class_name, ...) \
34 enum class class_name : uint32_t { \
35  __VA_ARGS__ \
36 }; \
37 DEFINE_ENUM_CLASS_OR_OPERATOR(class_name) \
38 DEFINE_ENUM_CLASS_AND_OPERATOR(class_name) \
39 
40 #endif // !ECVL_MACROS_H_