I have the following in a for loop and the compiler says ‘operator = is ambiguous’. Not sure how to solve this issue, can anyone help?
rootelement = document->getDocumentElement();
boost::interprocess::unique_ptr<DOMNodeIterator, release_deleter> itera (document->createNodeIterator(rootelement, DOMNodeFilter::SHOW_ALL, NULL, true));
for(boost::interprocess::unique_ptr<DOMNode, release_deleter> current (itera->nextNode()); current != 0; current = boost::interprocess::unique_ptr<DOMNode, release_deleter> (itera->nextNode())) // Last assignment on current is ambiguous
Full error:
*
\XMLDocument.cpp(193) : error C2593: 'operator =' is ambiguous
c:\Program Files\boost\boost_1_44\boost\interprocess\smart_ptr\unique_ptr.hpp(249): could be 'boost::interprocess::unique_ptr<T,D> &boost::interprocess::unique_ptr<T,D>::operator =(int boost::interprocess::unique_ptr<T,D>::nat::* )'
with
[
T=xercesc_3_1::DOMNode,
D=release_deleter
]
unique_ptr.hpp(211): or 'boost::interprocess::unique_ptr<T,D> &boost::interprocess::unique_ptr<T,D>::operator =(boost::interprocess::rv<boost::interprocess::unique_ptr<T,D>> &)'
with
[
T=xercesc_3_1::DOMNode,
D=release_deleter
]
while trying to match the argument list '(boost::interprocess::unique_ptr<T,D>, boost::interprocess::unique_ptr<T,D>)'
with
[
T=xercesc_3_1::DOMNode,
D=release_deleter
]
and
[
T=xercesc_3_1::DOMNode,
D=release_deleter
]
\XMLDocument.cpp(193) : see reference to class template instantiation 'boost::interprocess::detail::unique_ptr_error<T>' being compiled
with
[
T=boost::interprocess::unique_ptr<xercesc_3_1::DOMNode,release_deleter>
]
XMLDocument.cpp(193) : see reference to class template instantiation 'boost::interprocess::detail::unique_ptr_error<T>' being compiled
with
[
T=xercesc_3_1::DOMNode *
]
\XMLDocument.cpp(193) : see reference to class template instantiation 'boost::interprocess::detail::unique_ptr_error<T>' being compiled
with
[
T=xercesc_3_1::DOMNode *
]
XMLDocument.cpp(192) : see reference to class template instantiation 'boost::int
erprocess::detail::unique_ptr_error<T>' being compiled
with
[
T=xercesc_3_1::DOMNodeIterator *
]
*
Like Stephane says,
unique_ptr‘s maintain uniqueness unless you explicitly move them, or assign an rvalue to them. Normally, your code would be fine, but since you’re faking rvalues, you’ll need to move it explicitly.I’ve never used
boost::interprocess::unique_ptr, but it looks like you want this:Simpler might be: