I have been trying to debug this for a while now without any luck. I was hoping to get some help here. Apologies if my question isn't relevant or something, I'm new.
So basically what I have is:
#include <iostream>
template<typename T> class Node {
using NodePtr = std::shared_ptr<Node<T>>;
private:
Node() {}
T value{};
NodePtr parent;
NodePtr child;
public:
Node(const T& value) : value{ value } {}
Node(const T& value, NodePtr child) : Node(value)
{
this->child = child;
if (child != NULL)
{
//problem here?
child->parent = NodePtr(this);
/*The equivalent in C# works perfectly fine:*/
/*this.child = child;
if(child != null) {
child.parent = this;
}*/
}
}
const T& Value() const { return value; }
T& ValueRef() const { return value; }
NodePtr Parent() const { return parent; }
NodePtr Child() const { return child; }
};
template<typename T> std::ostream& operator<<(std::ostream& stream, const Node<T>& node) {
stream << "{" << node.Value() << "}";
return stream;
}
int main()
{
Node<int> n{ 5, std::make_shared<Node<int>>(3) };
std::cout << n;
}
I can implement this easily without using smart pointers, but I'm trying to learn them so there's that.
The assertion that is failing: "is_block_type_valid(header->_block_use)"
Any help would be appreciated, thank you.