Skip to content

Commit 8aa40fa

Browse files
committed
bit: Use std::byte in bit_cast implementation
1 parent fa11236 commit 8aa40fa

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/stdgpu/impl/bit_detail.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#ifndef STDGPU_BIT_DETAIL_H
1717
#define STDGPU_BIT_DETAIL_H
1818

19+
#include <cstddef>
20+
1921
#include <stdgpu/contract.h>
2022
#include <stdgpu/limits.h>
2123

@@ -136,12 +138,12 @@ bit_cast(const From& object)
136138
To result;
137139

138140
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
139-
auto* result_bytes = reinterpret_cast<unsigned char*>(&result);
141+
auto* result_bytes = reinterpret_cast<std::byte*>(&result);
140142

141143
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
142-
const auto* object_bytes = reinterpret_cast<const unsigned char*>(&object);
144+
const auto* object_bytes = reinterpret_cast<const std::byte*>(&object);
143145

144-
for (unsigned int i = 0; i < sizeof(To); ++i)
146+
for (std::size_t i = 0; i < sizeof(To); ++i)
145147
{
146148
result_bytes[i] = object_bytes[i];
147149
}

0 commit comments

Comments
 (0)