diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-11-22 06:28:03 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-11-22 06:28:03 -0800 |
commit | 018ced49ce429b123cbf63534d75f16ca91a96c2 (patch) | |
tree | a6c34ea9310bd3399392555b2d685e2fd4c8743f /starts/meaning-vm/helpers.hpp | |
parent | 55f586437b52bda32793a376f8ea5df9fb1b89e2 (diff) | |
download | standingwithresilience-018ced49ce429b123cbf63534d75f16ca91a96c2.tar.gz standingwithresilience-018ced49ce429b123cbf63534d75f16ca91a96c2.zip |
decl references in one expression
Diffstat (limited to 'starts/meaning-vm/helpers.hpp')
-rw-r--r-- | starts/meaning-vm/helpers.hpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/starts/meaning-vm/helpers.hpp b/starts/meaning-vm/helpers.hpp index d69519c..f1b9e36 100644 --- a/starts/meaning-vm/helpers.hpp +++ b/starts/meaning-vm/helpers.hpp @@ -2,5 +2,23 @@ #include "concept.hpp" -#define r(concept) \ - ref concept = #concept +#include <sstream> + +template <typename... T> +void __helper_init_ref_names(std::string names, T &... refrefs) +{ + std::stringstream ss(names); + ref* refptrs[] = {&refrefs...}; + for (std::size_t i = 0; i < sizeof...(refrefs); ++ i) { + std::string name; + ss >> name; + if (name[name.size() - 1] == ',') { + name = name.substr(0, name.size() - 1); + } + refptrs[i]->ptr = ref(name).ptr; + } +} + +#define decl(...) \ + ref __VA_ARGS__; \ + __helper_init_ref_names(#__VA_ARGS__, __VA_ARGS__) |