UraniumCompute 0.1.0
A GPU accelerated parallel task scheduler
Byte.h
1#pragma once
2#include <UnCompute/Base/Flags.h>
3#include <iomanip>
4
5namespace UN
6{
8 enum class Byte : UInt8
9 {
10 };
11
12 static_assert(sizeof(Byte) == 1);
13
15 template<class T>
16 inline std::enable_if_t<std::is_integral_v<T>, Byte*> un_byte_cast(T* ptr)
17 {
18 return reinterpret_cast<Byte*>(ptr);
19 }
20
22 template<class T>
23 inline std::enable_if_t<std::is_integral_v<T>, const Byte*> un_byte_cast(const T* ptr)
24 {
25 return reinterpret_cast<const Byte*>(ptr);
26 }
27
28 template<class TOStream>
29 inline TOStream& operator<<(TOStream& stream, Byte byte)
30 {
31 return stream << "0x" << std::setfill('0') << std::setw(2) << std::right << std::hex << static_cast<Int32>(byte);
32 }
33} // namespace UN