-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathreflection_non_member_function.cpp
More file actions
38 lines (27 loc) · 973 Bytes
/
Copy pathreflection_non_member_function.cpp
File metadata and controls
38 lines (27 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <reflex/reflex>
using namespace reflex;
class SomeClass {
public:
static std::string concat(const std::string& str, unsigned int nb) {
std::cout << "concat(" << str << ", " << nb << ")" << std::endl;
return str + std::to_string(nb);
}
};
REGISTER_CLASS_FUNCTIONS(SomeClass, (concat))
int basic_fct_1(float f, char c) {
std::cout << "basic_fct_1(" << f << ", " << c << ")" << std::endl;
return 42;
}
void basic_fct_2(void) {
std::cout << "basic_fct_2()" << std::endl;
}
REGISTER_FUNCTIONS((basic_fct_1)(basic_fct_2))
int main(void) {
auto res1 = reflection_maker<std::string(const std::string&, unsigned int)>::invoke("SomeClass", "concat", std::string("hello"), 42);
std::cout << res1 << std::endl;
auto res2 = reflection_maker<int(float, char)>::invoke("basic_fct_1", 4.2, 'z');
std::cout << res2 << std::endl;
reflection_maker<void()>::invoke("basic_fct_2");
return 0;
}