diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-11-26 12:25:58 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-11-26 12:25:58 -0800 |
commit | cae16e6c034808199f12a37ec0bdb4822c988dca (patch) | |
tree | d2ec4daa9650e4e58d159bc3ef172d05947b2db2 /starts/meaning-vm/level-0/concept.hpp | |
parent | 0a9e019f082578895e4ebc88e4b89188da17947f (diff) | |
download | standingwithresilience-cae16e6c034808199f12a37ec0bdb4822c988dca.tar.gz standingwithresilience-cae16e6c034808199f12a37ec0bdb4822c988dca.zip |
switch data to use std::any and merge value struct with concept
Diffstat (limited to 'starts/meaning-vm/level-0/concept.hpp')
-rw-r--r-- | starts/meaning-vm/level-0/concept.hpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/starts/meaning-vm/level-0/concept.hpp b/starts/meaning-vm/level-0/concept.hpp index 3bd1609..d57ccfc 100644 --- a/starts/meaning-vm/level-0/concept.hpp +++ b/starts/meaning-vm/level-0/concept.hpp @@ -2,6 +2,7 @@ #include "common.hpp" +#include <any> #include <map> #include <vector> @@ -12,6 +13,9 @@ struct concept { // a concept is made of concept-typed links to other concepts std::multimap<concept*,concept*> links; + // and optional associated arbitrary data + std::any data; + using array = std::vector<concept*>; concept* id(); @@ -30,10 +34,10 @@ struct concept void set(concept* type, concept* target); template <typename T> - value<T>* vget(concept* type) const { return static_cast<value<T>*>(get(type)); } + T & vget(concept* type) const { return get(type)->val<T>(); } template <typename T> - value<T>* val() { return this; } + T & val() { return std::any_cast<T&>(data); } }; } |