CsCrypto
2.0.0
Main Page
Overview
Classes
Support
byte.h
1
/***********************************************************************
2
*
3
* Copyright (c) 2021-2025 Tim van Deurzen
4
* Copyright (c) 2021-2025 Barbara Geller
5
* Copyright (c) 2021-2025 Ansel Sermersheim
6
*
7
* This file is part of CsCrypto.
8
*
9
* CsCrypto is free software which is released under the BSD 2-Clause license.
10
* For license details refer to the LICENSE provided with this project.
11
*
12
* CsCrypto is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
*
16
* https://opensource.org/licenses/BSD-2-Clause
17
*
18
***********************************************************************/
19
20
#
ifndef
CS_CRYPTO_UTIL_BYTE_H
21
#
define
CS_CRYPTO_UTIL_BYTE_H
22
23
#
include
<
util
/
tools
/
crypto_traits
.
h
>
24
25
#
include
<
cstddef
>
26
#
include
<
type_traits
>
27
28
namespace
cs_crypto::util {
29
30
inline
const
unsigned
char
*from_byte_ptr(
const
std::byte *value)
31
{
32
return
reinterpret_cast
<
const
unsigned
char
*>(value);
33
}
34
35
inline
unsigned
char
*from_byte_ptr(std::byte *value)
36
{
37
return
reinterpret_cast
<
unsigned
char
*>(value);
38
}
39
40
template
<
typename
T>
41
inline
const
std::byte *to_byte_ptr(
const
T *value)
42
{
43
static_assert
(cs_crypto::traits::is_uniquely_represented_byte_v<T>,
"Unable to convert const T * to const std::byte *"
);
44
return
reinterpret_cast
<
const
std::byte *>(value);
45
}
46
47
}
// namespace cs_crypto::util
48
49
#
endif
util
conversions
byte.h
Generated on Fri Mar 28 2025 16:00 by
2.0.0