e265677727
7df4ec2 clear bit git-subtree-dir: external/ircolib git-subtree-split: 7df4ec22463394c2763fef61b581b3d2980778ef
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#pragma once
|
|
#include <cstdint>
|
|
|
|
namespace ircolib {
|
|
using u8 = uint8_t;
|
|
using u16 = uint16_t;
|
|
using u32 = uint32_t;
|
|
using u64 = uint64_t;
|
|
using s8 = int8_t;
|
|
using s16 = int16_t;
|
|
using s32 = int32_t;
|
|
using s64 = int64_t;
|
|
|
|
template <typename T, std::size_t bit>
|
|
static constexpr bool is_bit_set(const T &val) {
|
|
return val & (1 << bit);
|
|
}
|
|
|
|
template <typename T, std::size_t bit>
|
|
static constexpr void set_bit(T &val) {
|
|
val |= 1 << bit;
|
|
}
|
|
|
|
template <typename T>
|
|
inline bool is_bit_set(const T &val, const std::size_t &bit) {
|
|
return val & (1 << bit);
|
|
}
|
|
|
|
template <typename T>
|
|
inline void set_bit(T &val, const std::size_t &bit) {
|
|
val |= 1 << bit;
|
|
}
|
|
|
|
template <typename T>
|
|
inline void clear_bit(T &val, const std::size_t &bit) {
|
|
val &= ~(1 << bit);
|
|
}
|
|
} // namespace ircolib
|
|
|
|
constexpr ircolib::u32 operator""_kib(const unsigned long long v) { return v * 1024; }
|
|
constexpr ircolib::u32 operator""_mib(const unsigned long long v) { return v * 1024 * 1024; }
|
|
constexpr ircolib::u32 operator""_gib(const unsigned long long v) { return v * 1024 * 1024 * 1024; }
|