implement move - copy constructor seems to be broken!
This commit is contained in:
parent
7c84064905
commit
7c7bf899b7
@ -42,6 +42,16 @@ inline Node::Node(const Node& rhs)
|
||||
m_pMemory(rhs.m_pMemory),
|
||||
m_pNode(rhs.m_pNode) {}
|
||||
|
||||
inline Node::Node(Node&& rhs)
|
||||
: m_isValid(rhs.m_isValid),
|
||||
m_pMemory(rhs.m_pMemory),
|
||||
m_pNode(rhs.m_pNode) {
|
||||
|
||||
rhs.m_pMemory.reset(new detail::memory_holder);
|
||||
rhs.m_pNode = &rhs.m_pMemory->create_node();
|
||||
rhs.m_pNode->set_null();
|
||||
}
|
||||
|
||||
inline Node::Node(Zombie) : m_isValid(false), m_pNode(NULL) {}
|
||||
|
||||
inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory)
|
||||
@ -247,6 +257,20 @@ inline Node& Node::operator=(const Node& rhs) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Node& Node::operator=(Node&& rhs) {
|
||||
if (!m_isValid || !rhs.m_isValid)
|
||||
throw InvalidNode();
|
||||
if (is(rhs))
|
||||
return *this;
|
||||
AssignNode(rhs);
|
||||
|
||||
rhs.m_pMemory.reset(new detail::memory_holder);
|
||||
rhs.m_pNode = &rhs.m_pMemory->create_node();
|
||||
rhs.m_pNode->set_null();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Node::AssignData(const Node& rhs) {
|
||||
if (!m_isValid || !rhs.m_isValid)
|
||||
throw InvalidNode();
|
||||
|
||||
@ -47,6 +47,8 @@ class YAML_CPP_API Node {
|
||||
explicit Node(const T& rhs);
|
||||
explicit Node(const detail::iterator_value& rhs);
|
||||
Node(const Node& rhs);
|
||||
Node(Node&& rhs);
|
||||
|
||||
~Node();
|
||||
|
||||
YAML::Mark Mark() const;
|
||||
@ -81,6 +83,7 @@ class YAML_CPP_API Node {
|
||||
template <typename T>
|
||||
Node& operator=(const T& rhs);
|
||||
Node& operator=(const Node& rhs);
|
||||
Node& operator=(Node&& rhs);
|
||||
void reset(const Node& rhs = Node());
|
||||
|
||||
// size/iterator
|
||||
|
||||
Loading…
Reference in New Issue
Block a user