diff options
Diffstat (limited to 'starts/meaning-vm/concept.hpp')
-rw-r--r-- | starts/meaning-vm/concept.hpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/starts/meaning-vm/concept.hpp b/starts/meaning-vm/concept.hpp index e5cddec..c69ff10 100644 --- a/starts/meaning-vm/concept.hpp +++ b/starts/meaning-vm/concept.hpp @@ -15,19 +15,22 @@ struct ref ref(ref const &) = default; concept* operator->() { return ptr; } bool operator==(ref const & that) const { return this->ptr == that.ptr; } + bool operator!=(ref const & that) const { return this->ptr != that.ptr; } bool operator<(ref const &) const { throw std::logic_error("ref has redefined syntax sugar: do not use in containers"); } - // for helpers + // for helpers, mostly names ref(std::string const &); ref(char const * str) : ref(std::string(str)) { } ref(bool b) : ref(b ? "true" : "false") { } ref() : ref("nothing") { } - value<std::string> & name() const; + value<std::string> & name() const; // this is a reference so that its char pointer lasts operator const char *() const; - ref operator=(ref other); // helper constructs new concept with this as link - ref operator[](ref links); // helper sets all links from passed concept + // helper linking syntax sugar + ref operator=(ref that); + ref operator<<(ref target); + ref operator[](ref links); bool isa(ref what) const; bool isan(ref what) const; @@ -42,11 +45,13 @@ struct vref value<T>* operator->() { return ptr; } operator T const &() const { return *ptr; } - vref(ref const & other) : ptr(static_cast<value<T>*>(other.ptr)) { } + vref(T const & val); + + vref(ref const & that) : ptr(static_cast<value<T>*>(that.ptr)) { } operator ref() { return ptr; } // for use by containers - //bool operator<(ref const & other) const { return ptr < other.ptr; } + //bool operator<(ref const & that) const { return ptr < that.ptr; } value<T> * ptr; }; @@ -60,9 +65,9 @@ struct concept ref id(); bool linked(ref type); bool linked(ref type, ref target); - ref get(ref type); // returns first + ref get(ref type, bool quick = false); // returns first template <typename T> - vref<T> vget(ref type) { return get(type); } + vref<T> vget(ref type, bool quick = false) { return get(type, quick); } array getAll(ref type); void link(ref type, ref target); void unlink(ref type, ref target); @@ -72,7 +77,7 @@ struct concept template <typename T> struct value : public concept, public T { - value(T const & val) : T(val) {} + value(T const & val) : T(val) { } value(value<T> const & val) = default; static value<T>& of(ref c) { |