mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-07 06:58:15 +01:00
cast_util: Add FptrCast
Reduce unnecessary type duplication when casting a lambda to a function pointer.
This commit is contained in:
parent
fe583aa076
commit
bd88286b21
7 changed files with 38 additions and 26 deletions
|
|
@ -9,6 +9,8 @@
|
|||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#include <mp/traits/function_info.h>
|
||||
|
||||
namespace Dynarmic::Common {
|
||||
|
||||
/// Reinterpret objects of one type as another by bit-casting between object representations.
|
||||
|
|
@ -35,4 +37,10 @@ inline Dest BitCastPointee(const SourcePtr source) noexcept {
|
|||
return reinterpret_cast<Dest&>(dest);
|
||||
}
|
||||
|
||||
/// Cast a lambda into an equivalent function pointer.
|
||||
template <class Function>
|
||||
inline auto FptrCast(Function f) noexcept {
|
||||
return static_cast<mp::equivalent_function_type<Function>*>(f);
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::Common
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue