Elements
6.3.3
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
ElementsKernel
ElementsKernel
_impl
FuncPtrCast.tpp
Go to the documentation of this file.
1
20
21
// IWYU pragma: private, include "ElementsKernel/FuncPtrCast.h"
22
23
#ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_FUNCPTRCAST_IMPL_
24
#error "This file should not be included directly! Use ElementsKernel/FuncPtrCast.h instead"
25
#else
26
27
#include <cstring>
// for memcpy
28
#include <type_traits>
// for is_pointer
29
30
namespace
Elements
{
31
32
namespace
System
{
33
34
template
<
typename
DESTPTR,
typename
SRC>
35
constexpr
DESTPTR
FuncPtrCast
(SRC*
const
src_p)
noexcept
{
36
static_assert
(std::is_pointer<DESTPTR>::value,
"must be a pointer"
);
37
DESTPTR dst_p =
nullptr
;
// must initialize to be a valid constexpr...
38
std::memcpy
(&dst_p, &src_p,
sizeof
(dst_p));
39
return
dst_p;
40
}
41
42
}
// namespace System
43
44
}
// namespace Elements
45
46
#endif
// ELEMENTSKERNEL_ELEMENTSKERNEL_FUNCPTRCAST_IMPL_
Elements::System::FuncPtrCast
constexpr DESTPTR FuncPtrCast(SRC *const src_p) noexcept
Cast from void * to function pointer.
std::memcpy
T memcpy(T... args)
Elements::System
Definition
FuncPtrCast.h:34
Elements
Definition
Auxiliary.h:43
Generated by
1.14.0