10#ifndef PCAL9555_DETAIL_HPP
11#define PCAL9555_DETAIL_HPP
17namespace pcal9555::detail {
32template <
typename Port,
typename Sig>
33 requires std::is_class_v<Port> && std::is_function_v<Sig>
37template <
typename Port,
typename R,
typename... Args>
38 requires std::is_class_v<Port>
39struct ExactHook<Port, R(Args...) noexcept> {
41 static void Take(R (Port::*hook)(Args...) noexcept) noexcept;
43 static void Take(R (Port::*hook)(Args...) const noexcept) noexcept;
48concept ClassType = std::is_class_v<T>;
53inline constexpr bool kAlwaysFalse =
false;
57concept Enumeration = std::is_enum_v<E>;
63template <Enumeration E>
64[[nodiscard]]
constexpr std::underlying_type_t<E> ToUnderlying(E e)
noexcept {
65 return static_cast<std::underlying_type_t<E>
>(e);
73template <Enumeration E>
74[[nodiscard]]
constexpr bool IsEnumerator(E e, E last)
noexcept {
75 return static_cast<uint32_t
>(ToUnderlying(e)) <=
static_cast<uint32_t
>(ToUnderlying(last));
80inline void LiteralOutOfRange() noexcept {}
86consteval uint8_t
operator""_u8(
unsigned long long value)
noexcept {
87 if (value > 0xFFULL) {
90 return static_cast<uint8_t
>(value);
94consteval uint16_t
operator""_u16(
unsigned long long value)
noexcept {
95 if (value > 0xFFFFULL) {
98 return static_cast<uint16_t
>(value);
105consteval uint32_t
operator""_u32(
unsigned long long value)
noexcept {
106 if (value > 0xFFFF'FFFFULL) {
109 return static_cast<uint32_t
>(value);