a few lines of macros for making a printable enum.
using some templates with some hacky macros to allow matching on the contents of a std::variant, and getting the underlying value immediately.
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 <stdio.h> | |
| // Enhances `for` to automatically iterate over an array. Item cannot be used to modify the contents of array. | |
| #if __STDC_VERSION__ < 202311L | |
| #define each(item, ...) \ | |
| (int no_loops = 1, break_p = 2; (no_loops >= 1) && (break_p == 2);) \ | |
| for(typeof(*(__VA_ARGS__)) *foreach_p = (__VA_ARGS__), *foreach_p2 = foreach_p, (item) = {}; \ | |
| (foreach_p < &((foreach_p2)[sizeof(__VA_ARGS__) / sizeof(*(__VA_ARGS__))])) && \ | |
| ((break_p = (break_p == 2)?0:break_p), no_loops); ++foreach_p) \ | |
| if((__builtin_memcpy(&(item), foreach_p, sizeof(item))), 0){}else | |
| #else |
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> | |
| #include <vector> | |
| #include <memory> | |
| #include <cereal/archives/binary.hpp> | |
| #include <cereal/types/vector.hpp> | |
| #include <cereal/types/string.hpp> | |
| #include <cereal/types/base_class.hpp> | |
| #include <cereal/types/memory.hpp> | |
| #include <cereal/access.hpp> |