Skip to content

Commit 89e6c19

Browse files
authored
Update README.md
1 parent 97d403d commit 89e6c19

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,16 @@ Manual registration with string-based type identifiers can become error-prone an
7373

7474
### RTL in action:
7575

76-
Lookup the `Person` class by its registered name:
76+
Lookup the `Person` class by its registered name using a string literal:
7777
```c++
7878
std::optional<rtl::Record> classPerson = cxx::mirror().getRecord("Person");
7979
if (!classPerson) { /* Class not registered. */ }
8080
```
81+
When using `clang-mirror` output, prefer the generated compile-time identifier:
82+
```c++
83+
std::optional<rtl::Record> classPerson = cxx::mirror().getRecord(cxx::type::Person::id);
84+
if (!classPerson) { /* Class not registered. */ }
85+
```
8186
`rtl::CxxMirror` returns two reflection metadata objects: `rtl::Record` for any registered type (class, struct, or POD) and `rtl::Function` for non-member functions.
8287

8388
From `rtl::Record`, registered member functions can be obtained as `rtl::Method`. These are metadata descriptors, not callables. Callable entities – i.e., functors, are produced by explicitly providing the argument types we intend to pass.
@@ -102,6 +107,11 @@ Looking up a member function by name:
102107
std::optional<rtl::Method> oGetName = classPerson->getMethod("getName");
103108
if (!oGetName) { /* Member function not registered */ }
104109
```
110+
Or, preferably, using the generated member-function identifier:
111+
```c++
112+
std::optional<rtl::Method> oGetName = classPerson->getMethod(cxx::type::Person::fn::getName::id);
113+
if (!oGetName) { /* Member function not registered */ }
114+
```
105115
And obtain a complete type-aware functor:
106116
```c++
107117
rtl::method<Person, std::string()> getName = oGetName->targetT<Person>().argsT()

0 commit comments

Comments
 (0)