Created
September 13, 2025 01:03
-
-
Save agrif/4d602ecd05a3beb088c5848dc5f93564 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| class TransmitEventClass { | |
| public: | |
| size_t val; | |
| TransmitEventClass(size_t val) : val(val) {} | |
| }; | |
| // just to allow << on all TransmitEvent | |
| std::ostream& operator<<(std::ostream& os, const TransmitEventClass& ev) { | |
| os << ev.val; | |
| return os; | |
| } | |
| // !!!! | |
| // !!!! fine with size_t, segfault with TransmitEventClass | |
| // !!!! | |
| //typedef size_t TransmitEvent; | |
| typedef TransmitEventClass TransmitEvent; | |
| TransmitEvent ev_tmit0(0x1000); | |
| class Rule { | |
| public: | |
| size_t recv; | |
| TransmitEvent *const *tmit_begin; | |
| TransmitEvent *const *tmit_end; | |
| Rule(size_t recv, std::initializer_list<TransmitEvent*> tmit) | |
| : recv(recv), tmit_begin(tmit.begin()), tmit_end(tmit.end()) | |
| {} | |
| TransmitEvent *const *begin() const { | |
| return tmit_begin; | |
| } | |
| TransmitEvent *const *end() const { | |
| return tmit_end; | |
| } | |
| }; | |
| std::initializer_list<Rule> rules = { | |
| {0x01, {&ev_tmit0}}, | |
| }; | |
| int main(void) { | |
| std::cout << "Hello, world!" << std::endl; | |
| for (const Rule &rule : rules) { | |
| for (TransmitEvent *ev : rule) { | |
| std::cout << (*ev) << std::endl; | |
| } | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment