WS2812_RMT Driver 0.1.0
API reference
Loading...
Searching...
No Matches
ws2812_rmt_detail.hpp
Go to the documentation of this file.
1
10#ifndef WS2812_RMT_DETAIL_HPP
11#define WS2812_RMT_DETAIL_HPP
12
13#include <concepts>
14#include <cstdint>
15#include <type_traits>
16
17namespace ws2812_rmt::detail {
18
32template <typename Port, typename Sig>
33 requires std::is_class_v<Port> && std::is_function_v<Sig>
34struct ExactHook;
35
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;
44};
45
47template <typename T>
48concept ClassType = std::is_class_v<T>;
49
52template <ClassType>
53inline constexpr bool kAlwaysFalse = false;
54
56template <typename E>
57concept Enumeration = std::is_enum_v<E>;
58
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);
66}
67
72template <Enumeration E>
73struct EnumLast;
74
79template <Enumeration E>
80[[nodiscard]] constexpr bool IsEnumerator(E e) noexcept {
81 return static_cast<uint32_t>(ToUnderlying(e)) <=
82 static_cast<uint32_t>(ToUnderlying(EnumLast<E>::kValue));
83}
84
85} // namespace ws2812_rmt::detail
86
87#endif // WS2812_RMT_DETAIL_HPP