[#BloombergLP-bslalg-RbTreeUtil-copyTree]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslalg.adoc[bslalg]::xref:BloombergLP/bslalg/RbTreeUtil.adoc[RbTreeUtil]::copyTree
:relfileprefix: ../../../
:mrdocs:

Load, into the specified `result`, a collection of newly created nodes having the same red&hyphen;black tree structure as that of the specified `original` tree, where each node in the returned tree is created by invoking `nodeFactory&hyphen;&gt;createNode` on the corresponding `original` node&semi; if an exception occurs, use `nodeFactory&hyphen;&gt;deleteNode` to destroy any newly created nodes, and propagate the exception to the caller (i&period;e&period;, this operation provides the _strong_ exception guarantee)&period; `FACTORY` shall be a class providing two methods that can be called as if they had the following signatures&colon; &grave; RbTreeNode &ast;createNode(const RbTreeNode&amp;)&semi; void deleteNode(RbTreeNode &ast;)&semi; &grave; The behavior is undefined unless `result` is an empty tree, `original` is a well&hyphen;formed (see `isWellFormed`), and `nodeFactory&hyphen;&gt;deleteNode` does not throw&period;

== Synopsis

Declared in `&lt;bslalg&lowbar;rbtreeutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class FACTORY&gt;
static
void
copyTree(
    xref:BloombergLP/bslalg/RbTreeAnchor.adoc[RbTreeAnchor]* result,
    xref:BloombergLP/bslalg/RbTreeAnchor.adoc[RbTreeAnchor] const& original,
    FACTORY* nodeFactory);
----


[.small]#Created with https://www.mrdocs.com[MrDocs]#
