wut/include/wut_types.h
GaryOderNichts 2c98cc91aa
Some checks failed
C/C++ CI / ubuntu-latest (push) Has been cancelled
Run clang-format
`find . -regex '.*\.\(cpp\|hpp\|cu\|cuh\|c\|h\)' -exec clang-format -style=file -i {} \;`
2025-06-05 11:06:04 +01:00

64 lines
6.1 KiB
C++

#pragma once
#include <stdalign.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
typedef int32_t BOOL;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#if defined(__cplusplus) && (__cplusplus >= 201402L)
#include <type_traits>
#define WUT_ENUM_BITMASK_TYPE(_type) \
extern "C++" { \
namespace \
{ \
constexpr inline _type \
operator~(_type lhs) \
{ \
return static_cast<_type>(~static_cast<std::underlying_type_t<_type>>(lhs)); \
} \
constexpr inline _type \
operator&(_type lhs, _type rhs) \
{ \
return static_cast<_type>(static_cast<std::underlying_type_t<_type>>(lhs) & static_cast<std::underlying_type_t<_type>>(rhs)); \
} \
constexpr inline _type \
operator|(_type lhs, _type rhs) \
{ \
return static_cast<_type>(static_cast<std::underlying_type_t<_type>>(lhs) | static_cast<std::underlying_type_t<_type>>(rhs)); \
} \
constexpr inline _type \
operator^(_type lhs, _type rhs) \
{ \
return static_cast<_type>(static_cast<std::underlying_type_t<_type>>(lhs) ^ static_cast<std::underlying_type_t<_type>>(rhs)); \
} \
inline _type & \
operator&=(_type &lhs, _type rhs) \
{ \
return reinterpret_cast<_type &>(reinterpret_cast<std::underlying_type_t<_type> &>(lhs) &= static_cast<std::underlying_type_t<_type>>(rhs)); \
} \
inline _type & \
operator|=(_type &lhs, _type rhs) \
{ \
return reinterpret_cast<_type &>(reinterpret_cast<std::underlying_type_t<_type> &>(lhs) |= static_cast<std::underlying_type_t<_type>>(rhs)); \
} \
inline _type & \
operator^=(_type &lhs, _type rhs) \
{ \
return reinterpret_cast<_type &>(reinterpret_cast<std::underlying_type_t<_type> &>(lhs) ^= static_cast<std::underlying_type_t<_type>>(rhs)); \
} \
} \
}
#else
#define WUT_ENUM_BITMASK_TYPE(_type)
#endif