#ifndef TREE_NODE #define TREE_NODE #include #include #include #include namespace tree { //! @brief Compares type for a set of types //! //! @tparam T First object type //! @tparam Ts Variadic types //! //! @return True, if first type in the types; false otherwise //template //struct is_any : std::disjunction...> {}; class Node { public: using ChildrenType = std::vector; template Node(const T value) : _value(value) {}; template Node(const T value, const Childs& children) : _value(value), _children(children) {}; template auto get() { return _value } template void set(const T& value) { _value = value; } template bool exists(const T& value) const { for (const auto& child : _children) { if (child.get() == value) return true; } } template Node& operator[](const T& value) { for (auto& child : _children) { if (child.get() == value) return child; } throw "Child not found"; } size_t getStorageIndex() { return _value.index(); } private: using StorageType = std::variant; template struct StorageIndex { static_assert(false, "Storage type is string, double or int"); }; template <> static struct StorageIndex { size_t index = 0U; }; template <> static struct StorageIndex { size_t index = 1U; }; template <> static struct StorageIndex { size_t index = 2U; }; StorageType _value; ChildrenType _children; }; } // namespace tree #endif // !TREE_NODE