#pragma once

#include <array>
#include <bit>
#include <concepts>
#include <cstdint>

namespace kuiper
{
namespace utils
{
    namespace bits
    {
        template<typename T>
            requires std::integral<T>
        inline T set_bit_n(T value, std::uint8_t bit_n) {
            return value | (static_cast<T>(0b00000001) << (bit_n - 1));
        }

        template<typename T>
            requires std::integral<T>
        inline T unset_bit_n(T value, std::uint8_t bit_n) {
            return value & ~(static_cast<T>(0b00000001) << (bit_n - 1));
        }
    } // namespace bits

    namespace bytes
    {
        template<typename T>
        inline constexpr std::array<std::uint8_t, sizeof(T)> as_byte_array(T value) {
            return std::bit_cast<std::array<std::uint8_t, sizeof(T)>, T>(value);
        }
    } // namespace bytes
} // namespace utils
} // namespace kuiper
