mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-14 01:09:23 +02:00
refactor: Use reinterpret_cast where appropriate
Also, wrap reinterpret_cast into a CharCast to ensure it is only called on byte pointers.
This commit is contained in:
10
src/span.h
10
src/span.h
@ -5,10 +5,10 @@
|
||||
#ifndef BITCOIN_SPAN_H
|
||||
#define BITCOIN_SPAN_H
|
||||
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
#ifdef DEBUG
|
||||
#define CONSTEXPR_IF_NOT_DEBUG
|
||||
@ -267,9 +267,9 @@ Span<std::byte> MakeWritableByteSpan(V&& v) noexcept
|
||||
}
|
||||
|
||||
// Helper functions to safely cast to unsigned char pointers.
|
||||
inline unsigned char* UCharCast(char* c) { return (unsigned char*)c; }
|
||||
inline unsigned char* UCharCast(char* c) { return reinterpret_cast<unsigned char*>(c); }
|
||||
inline unsigned char* UCharCast(unsigned char* c) { return c; }
|
||||
inline unsigned char* UCharCast(std::byte* c) { return (unsigned char*)c; }
|
||||
inline unsigned char* UCharCast(std::byte* c) { return reinterpret_cast<unsigned char*>(c); }
|
||||
inline const unsigned char* UCharCast(const char* c) { return reinterpret_cast<const unsigned char*>(c); }
|
||||
inline const unsigned char* UCharCast(const unsigned char* c) { return c; }
|
||||
inline const unsigned char* UCharCast(const std::byte* c) { return reinterpret_cast<const unsigned char*>(c); }
|
||||
|
Reference in New Issue
Block a user