Commit 0ea32d79 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2105] Make setData() optionally return the old data

parent 65976ab2
......@@ -244,12 +244,21 @@ public:
/// \name Setter functions.
//@{
/// \brief Set the data stored in the node. If there is old data, it
/// is destroyed.
void setData(T* data) {
const DT deleter;
deleter(data_);
/// \brief Set the data stored in the node. If there is old data, it
/// is either returned or destroyed based on what is passed in \c
/// old_data.
/// \param data The new data to set.
/// \param old_data If \c NULL is passed here, any old data is
/// destroyed. Otherwise, the old data is returned
/// in this location.
void setData(T* data, T** old_data = NULL) {
if (old_data != NULL) {
*old_data = data;
} else {
const DT deleter;
deleter(data_);
}
data_ = data;
}
//@}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment