Atlas Game Manager
A game manager for f95 and dlsite written in c++
Loading...
Searching...
No Matches
FunctionDecomp.hpp
Go to the documentation of this file.
1//
2// Created by kj16609 on 6/23/23.
3//
4
5#pragma once
6#ifndef ATLASGAMEMANAGER_FUNCTIONDECOMP_HPP
7#define ATLASGAMEMANAGER_FUNCTIONDECOMP_HPP
8
9#include <concepts>
10#include <tuple>
11
12// Everything below here is just pure magic.
13// I'll try to decipher how the hell this works someday....
14template < typename Function >
15struct FunctionDecomp;
16
17template < typename Function >
18struct FunctionDecomp : public FunctionDecomp< decltype( &std::remove_reference< Function >::type::operator() ) >
19{};
20
21template < typename ClassType, typename ReturnType, typename... Args >
22struct FunctionDecomp< ReturnType ( ClassType::* )( Args... ) const > : FunctionDecomp< ReturnType ( * )( Args... ) >
23{};
24
25template < typename ClassType, typename ReturnType, typename... Args >
26struct FunctionDecomp< ReturnType ( ClassType::* )( Args... ) > : FunctionDecomp< ReturnType ( * )( Args... ) >
27{};
28
29template < typename ClassType, typename ReturnType, typename... Args >
30struct FunctionDecomp< ReturnType ( ClassType::* )( Args... ) noexcept > : FunctionDecomp< ReturnType ( * )( Args... ) >
31{};
32
33template < typename ClassType, typename ReturnType, typename... Args >
34struct FunctionDecomp< ReturnType ( ClassType::* )( Args... ) const noexcept > :
35 FunctionDecomp< ReturnType ( * )( Args... ) >
36{};
37
38template < typename ReturnType, typename... Args >
39struct FunctionDecomp< ReturnType ( * )( Args... ) >
40{
41 using ResultType = ReturnType;
42
43 using ArgTuple = std::tuple< Args... >;
44 template < std::size_t Index >
45 using arg = typename std::tuple_element< Index, ArgTuple >::type;
46 static constexpr std::size_t arg_size = sizeof...( Args );
47};
48
49template < typename Func >
51
52template < typename Func >
54#endif //ATLASGAMEMANAGER_FUNCTIONDECOMP_HPP
FunctionDecomp< Func >::ArgTuple FunctionTuple
Definition FunctionDecomp.hpp:53
FunctionDecomp< Func >::ResultType FunctionReturn
Definition FunctionDecomp.hpp:50
std::tuple< Args... > ArgTuple
Definition FunctionDecomp.hpp:43
typename std::tuple_element< Index, ArgTuple >::type arg
Definition FunctionDecomp.hpp:45
static constexpr std::size_t arg_size
Definition FunctionDecomp.hpp:46
ReturnType ResultType
Definition FunctionDecomp.hpp:41
Definition FunctionDecomp.hpp:19