Skip to content

Commit d6aedfe

Browse files
committed
Use std::bit_cast in plact of reinterpret_cast
1 parent 20e3094 commit d6aedfe

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/nbl/video/CJITIncludeLoader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <bit>
2+
13
#include "nbl/video/CJITIncludeLoader.h"
24

35
namespace nbl::video

tools/deviceGen/DeviceGen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def transformTraits(dict, line_format, json_type, line_format_params):
262262
parsed_type = "uint32_t"
263263
parsed_name += "BitPattern"
264264
parsed_value = f"asuint({parsed_value})"
265-
parsed_json_type = r"*reinterpret_cast<const uint32_t *>(&" + parsed_json_type
265+
parsed_json_type = r"std::bit_cast<uint32_t>(" + parsed_json_type
266266
parsed_cpp_name = parsed_cpp_name + r")"
267267

268268
if parsed_type.startswith("core::bitflag") or parsed_type.startswith("asset") or parsed_type.startswith("E_"):
@@ -299,7 +299,7 @@ def transformTraits(dict, line_format, json_type, line_format_params):
299299
if parsed_type == 'float':
300300
type_ext = "uint32_t"
301301
parsed_name = parsed_name[:index1] + "BitPattern"
302-
parsed_json_type = r"*reinterpret_cast<const uint32_t *>(&" + parsed_json_type
302+
parsed_json_type = r"std::bit_cast<uint32_t>(" + parsed_json_type
303303
parsed_cpp_name = parsed_cpp_name[:index1] + r")"
304304
for j, value in enumerate(value_ext):
305305
value_ext[j] = "asuint(" + value + ")"

0 commit comments

Comments
 (0)