Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:10

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include <type_traits>
0012 
0013 #define ACTS_DEFINE_ENUM_BITWISE_OPERATORS(enum_t)         \
0014   constexpr auto operator|(enum_t lhs, enum_t rhs) {       \
0015     return static_cast<enum_t>(                            \
0016         static_cast<std::underlying_type_t<enum_t>>(lhs) | \
0017         static_cast<std::underlying_type_t<enum_t>>(rhs)); \
0018   }                                                        \
0019                                                            \
0020   constexpr auto operator&(enum_t lhs, enum_t rhs) {       \
0021     return static_cast<enum_t>(                            \
0022         static_cast<std::underlying_type_t<enum_t>>(lhs) & \
0023         static_cast<std::underlying_type_t<enum_t>>(rhs)); \
0024   }                                                        \
0025                                                            \
0026   constexpr auto operator^(enum_t lhs, enum_t rhs) {       \
0027     return static_cast<enum_t>(                            \
0028         static_cast<std::underlying_type_t<enum_t>>(lhs) ^ \
0029         static_cast<std::underlying_type_t<enum_t>>(rhs)); \
0030   }                                                        \
0031                                                            \
0032   constexpr auto operator~(enum_t op) {                    \
0033     return static_cast<enum_t>(                            \
0034         ~static_cast<std::underlying_type_t<enum_t>>(op)); \
0035   }                                                        \
0036                                                            \
0037   constexpr auto& operator|=(enum_t& lhs, enum_t rhs) {    \
0038     lhs = lhs | rhs;                                       \
0039     return lhs;                                            \
0040   }                                                        \
0041                                                            \
0042   constexpr auto& operator&=(enum_t& lhs, enum_t rhs) {    \
0043     lhs = lhs & rhs;                                       \
0044     return lhs;                                            \
0045   }                                                        \
0046                                                            \
0047   constexpr enum_t& operator^=(enum_t& lhs, enum_t rhs) {  \
0048     lhs = lhs ^ rhs;                                       \
0049     return lhs;                                            \
0050   }