Commit e27f6ece authored by Sam Jenkins's avatar Sam Jenkins
Browse files

Re #25465 Removed raw owning pointers from DataObjects

parent 72bac705
......@@ -115,8 +115,8 @@ public:
Mantid::API::VolumeNormalization) const;
/// Setter for the masking region.
virtual void
setMDMasking(Mantid::Geometry::MDImplicitFunction *maskingRegion) = 0;
virtual void setMDMasking(
std::unique_ptr<Mantid::Geometry::MDImplicitFunction> maskingRegion) = 0;
/// Clear existing masks
virtual void clearMDMasking() = 0;
......
......@@ -502,8 +502,8 @@ public:
Mantid::Geometry::MDImplicitFunction *function = nullptr) const override;
/// Apply masking.
void
setMDMasking(Mantid::Geometry::MDImplicitFunction *maskingRegion) override;
void setMDMasking(std::unique_ptr<Mantid::Geometry::MDImplicitFunction>
maskingRegion) override;
/// Clear exsting masking.
void clearMDMasking() override;
......
......@@ -904,7 +904,8 @@ Axis *MatrixWorkspace::getAxis(const std::size_t &axisIndex) const {
/** Replaces one of the workspace's axes with the new one provided.
* @param axisIndex :: The index of the axis to replace
* @param newAxis :: A pointer to the new axis. The class will take ownership.
* @param newAxis :: A Unique_ptr to the new axis. The class will take
* ownership.
* @throw IndexError If the axisIndex given is outside the range of axes held
* by this workspace
* @throw std::runtime_error If the new axis is not of the correct length
......@@ -919,8 +920,19 @@ void MatrixWorkspace::replaceAxis(const std::size_t &axisIndex,
"Value of axisIndex is invalid for this workspace");
}
// If we're OK, then delete the old axis and set the pointer to the new one
delete m_axes[axisIndex];
m_axes[axisIndex] = newAxis;
m_axes[axisIndex] = std::move(newAxis);
}
/**
* Raw Pointer version of replaceAxis to allow it to work with python
*
* @param axisIndex :: The index of the axis to replace
* @param newAxis :: A pointer to the new axis. The class will take ownership.
*/
void MatrixWorkspace::pythonReplaceAxis(const std::size_t &axisIndex,
Axis *newAxis) {
replaceAxis(axisIndex, std::unique_ptr<Axis>(newAxis));
}
/**
......@@ -1798,7 +1810,7 @@ MDMasking for a Matrix Workspace has not been implemented.
@param :
*/
void MatrixWorkspace::setMDMasking(
Mantid::Geometry::MDImplicitFunction * /*maskingRegion*/) {
std::unique_ptr<Mantid::Geometry::MDImplicitFunction> /*maskingRegion*/) {
throw std::runtime_error(
"MatrixWorkspace::setMDMasking has no implementation");
}
......
......@@ -29,7 +29,7 @@ public:
BoxControllerNeXusIO(API::BoxController *const bc);
///@return true if the file to write events is opened and false otherwise
bool isOpened() const override { return m_File != nullptr; }
bool isOpened() const override { return m_File.get() != nullptr; }
/// get the full file name of the file used for IO operations
const std::string &getFileName() const override { return m_fileName; }
/**Return the size of the NeXus data block used in NeXus data array*/
......@@ -61,7 +61,7 @@ public:
// Auxiliary functions (non-virtual, used for testing)
int64_t getNDataColums() const { return m_BlockSize[1]; }
// get pointer to the Nexus file --> compatribility testing only.
::NeXus::File *getFile() { return m_File; }
::NeXus::File *getFile() { return m_File.get(); }
private:
/// Default size of the events block which can be written in the NeXus array
......@@ -73,7 +73,7 @@ private:
/// truncated to 64 bytes)
std::string m_fileName;
/// the file Handler responsible for Nexus IO operations;
::NeXus::File *m_File;
std::unique_ptr<::NeXus::File> m_File;
/// identifier if the file open only for reading or is in read/write
bool m_ReadOnly;
/// The size of the events block which can be written in the neXus array at
......
......@@ -169,10 +169,10 @@ private:
/** A vector that holds the event list for each spectrum; the key is
* the workspace index, which is not necessarily the pixelid.
*/
std::vector<EventList *> data;
std::vector<std::unique_ptr<EventList>> data;
/// Container for the MRU lists of the event lists contained.
mutable EventWorkspaceMRU *mru;
mutable std::unique_ptr<EventWorkspaceMRU> mru;
};
/// shared pointer to the EventWorkspace class
......
......@@ -90,10 +90,10 @@ public:
protected:
/// The most-recently-used list of dataY histograms
mutable std::vector<mru_listY *> m_bufferedDataY;
mutable std::vector<std::unique_ptr<mru_listY >> m_bufferedDataY;
/// The most-recently-used list of dataE histograms
mutable std::vector<mru_listE *> m_bufferedDataE;
mutable std::vector<std::unique_ptr<mru_listE >> m_bufferedDataE;
/// Mutex when adding entries in the MRU list
mutable Poco::RWLock m_changeMruListsMutexE;
......
......@@ -227,7 +227,7 @@ public:
protected:
// the pointer to the class, responsible for saving/restoring this class to
// the hdd
mutable Kernel::ISaveable *m_Saveable;
mutable std::unique_ptr<Kernel::ISaveable> m_Saveable;
/** Vector of MDEvent's, in no particular order. */
mutable std::vector<MDE> data;
......
......@@ -28,10 +28,9 @@ TMDE(MDBox)::~MDBox() {
// workspace
{
if (this->m_BoxController->isFileBacked()) {
this->m_BoxController->getFileIO()->objectDeleted(m_Saveable);
this->m_BoxController->getFileIO()->objectDeleted(m_Saveable.get());
}
}
delete m_Saveable;
}
}
//-----------------------------------------------------------------------------------------------
......@@ -164,7 +163,7 @@ TMDE(void MDBox)::clear() {
// used as free
// if (this->m_BoxController->useWriteBuffer())
if (m_Saveable)
this->m_BoxController->getFileIO()->objectDeleted(m_Saveable);
this->m_BoxController->getFileIO()->objectDeleted(m_Saveable.get());
// Clear all contents
this->m_signal = 0.0;
......@@ -173,8 +172,8 @@ TMDE(void MDBox)::clear() {
this->clearDataFromMemory();
}
TMDE(Kernel::ISaveable *MDBox)::getISaveable() { return m_Saveable; }
TMDE(Kernel::ISaveable *MDBox)::getISaveable() const { return m_Saveable; }
TMDE(Kernel::ISaveable *MDBox)::getISaveable() { return m_Saveable.get(); }
TMDE(Kernel::ISaveable *MDBox)::getISaveable() const { return m_Saveable.get(); }
//-----------------------------------------------------------------------------------------------
/** Clear the data[] vector ONLY but does not change the file-backed settings.
......@@ -276,7 +275,7 @@ TMDE(std::vector<MDE> &MDBox)::getEvents() {
// Tell the to-write buffer to discard the object (when no longer busy) as
// it has not been modified
this->m_BoxController->getFileIO()->toWrite(m_Saveable);
this->m_BoxController->getFileIO()->toWrite(m_Saveable.get());
// else: do nothing if the events are already in memory.
return data;
}
......@@ -305,7 +304,7 @@ TMDE(const std::vector<MDE> &MDBox)::getConstEvents() const {
// Tell the to-write buffer to discard the object (when no longer busy) as
// it has not been modified
this->m_BoxController->getFileIO()->toWrite(m_Saveable);
this->m_BoxController->getFileIO()->toWrite(m_Saveable.get());
// else: do nothing if the events are already in memory.
return data;
}
......@@ -871,7 +870,7 @@ TMDE(size_t MDBox)::addEvents(const std::vector<MDE> &events) {
TMDE(void MDBox)::setFileBacked(const uint64_t fileLocation,
const size_t fileSize, const bool markSaved) {
if (!m_Saveable)
m_Saveable = new MDBoxSaveable(this);
m_Saveable = std::make_unique<MDBoxSaveable>(this);
m_Saveable->setFilePosition(fileLocation, fileSize, markSaved);
}
......@@ -970,8 +969,7 @@ TMDE(void MDBox)::clearFileBacked(bool loadDiskBackedData) {
if (loadDiskBackedData)
m_Saveable->load();
// tell disk buffer that there are no point of tracking this box any more.
this->m_BoxController->getFileIO()->objectDeleted(m_Saveable);
delete m_Saveable;
this->m_BoxController->getFileIO()->objectDeleted(m_Saveable.get());
m_Saveable = nullptr;
}
}
......
......@@ -174,27 +174,26 @@ public:
/// Return true if the underlying box is a MDGridBox.
bool isGridBox() {
return dynamic_cast<MDGridBox<MDE, nd> *>(data) != nullptr;
return dynamic_cast<MDGridBox<MDE, nd>*>(data.get()) != nullptr;
}
/** @returns a pointer to the box (MDBox or MDGridBox) contained within, */
MDBoxBase<MDE, nd> *getBox() { return data; }
MDBoxBase<MDE, nd> *getBox() { return data.get(); }
/** @returns a pointer to the box (MDBox or MDGridBox) contained within, const
* version. */
const MDBoxBase<MDE, nd> *getBox() const { return data; }
const MDBoxBase<MDE, nd> *getBox() const { return data.get(); }
/** Set the base-level box contained within.
* Used in file loading */
void setBox(API::IMDNode *box) override {
if (data)
delete data;
data = dynamic_cast<MDBoxBase<MDE, nd> *>(box);
data = std::unique_ptr<MDBoxBase<MDE, nd>>(
dynamic_cast<MDBoxBase<MDE, nd> *>(box));
}
/// Apply masking
void
setMDMasking(Mantid::Geometry::MDImplicitFunction *maskingRegion) override;
setMDMasking(std::unique_ptr<Mantid::Geometry::MDImplicitFunction> maskingRegion) override;
/// Clear masking
void clearMDMasking() override;
......@@ -236,7 +235,7 @@ protected:
std::set<coord_t> &mid_points) const;
/** MDBox containing all of the events in the workspace. */
MDBoxBase<MDE, nd> *data;
std::unique_ptr<MDBoxBase<MDE, nd>> data;
/// Box controller in use
API::BoxController_sptr m_BoxController;
......
......@@ -60,7 +60,7 @@ TMDE(MDEventWorkspace)::MDEventWorkspace(
m_displayNormalizationHisto(preferredNormalizationHisto),
m_coordSystem(Kernel::None) {
// First box is at depth 0, and has this default boxController
data = new MDBox<MDE, nd>(m_BoxController.get(), 0);
data = std::make_unique<MDBox<MDE, nd>>(m_BoxController.get(), 0);
}
//-----------------------------------------------------------------------------------------------
......@@ -74,13 +74,14 @@ TMDE(MDEventWorkspace)::MDEventWorkspace(const MDEventWorkspace<MDE, nd> &other)
m_coordSystem(other.m_coordSystem) {
const MDBox<MDE, nd> *mdbox =
dynamic_cast<const MDBox<MDE, nd> *>(other.data);
dynamic_cast<const MDBox<MDE, nd> *>(other.data.get());
const MDGridBox<MDE, nd> *mdgridbox =
dynamic_cast<const MDGridBox<MDE, nd> *>(other.data);
dynamic_cast<const MDGridBox<MDE, nd> *>(other.data.get());
if (mdbox) {
data = new MDBox<MDE, nd>(*mdbox, m_BoxController.get());
data = std::make_unique<MDBox<MDE, nd>>(*mdbox, m_BoxController.get());
} else if (mdgridbox) {
data = new MDGridBox<MDE, nd>(*mdgridbox, m_BoxController.get());
data =
std::make_unique<MDGridBox<MDE, nd>>(*mdgridbox, m_BoxController.get());
} else {
throw std::runtime_error(
"MDEventWorkspace::copy_ctor(): unexpected data box type found.");
......@@ -90,7 +91,7 @@ TMDE(MDEventWorkspace)::MDEventWorkspace(const MDEventWorkspace<MDE, nd> &other)
//-----------------------------------------------------------------------------------------------
/** Destructor
*/
TMDE(MDEventWorkspace)::~MDEventWorkspace() { delete data; }
TMDE(MDEventWorkspace)::~MDEventWorkspace() { }
/**Make workspace file backed if it has not been already file backed
* @param fileName -- short or full file name of the file, which should be used
* as the file back end
......@@ -603,17 +604,17 @@ TMDE(size_t MDEventWorkspace)::addEvents(const std::vector<MDE> &events) {
*/
TMDE(void MDEventWorkspace)::splitBox() {
// Want MDGridBox
MDGridBox<MDE, nd> *gridBox = dynamic_cast<MDGridBox<MDE, nd> *>(data);
MDGridBox<MDE, nd> *gridBox = dynamic_cast<MDGridBox<MDE, nd> *>(data.get());
if (!gridBox) {
// Track how many MDBoxes there are in the overall workspace
this->m_BoxController->trackNumBoxes(data->getDepth());
MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(data);
MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(data.get());
if (!box)
throw std::runtime_error("MDEventWorkspace::splitBox() expected its data "
"to be a MDBox* to split to MDGridBox.");
gridBox = new MDGridBox<MDE, nd>(box);
delete data;
data = gridBox;
auto tempGridBox = std::make_unique<MDGridBox<MDE, nd>>(box);
data = std::move(tempGridBox);
}
}
......@@ -848,19 +849,18 @@ Setter for the masking region.
@param maskingRegion : Implicit function defining mask region.
*/
TMDE(void MDEventWorkspace)::setMDMasking(
Mantid::Geometry::MDImplicitFunction *maskingRegion) {
std::unique_ptr<Mantid::Geometry::MDImplicitFunction> maskingRegion) {
if (maskingRegion) {
std::vector<API::IMDNode *> toMaskBoxes;
// Apply new masks
this->data->getBoxes(toMaskBoxes, 10000, true, maskingRegion);
this->data->getBoxes(toMaskBoxes, 10000, true, maskingRegion.get());
for (const auto box : toMaskBoxes) {
box->clear();
box->clearFileBacked(false);
box->mask();
}
delete maskingRegion;
}
}
......
......@@ -401,8 +401,8 @@ public:
virtual std::vector<signal_t> getErrorDataVector() const;
/// Apply masking.
void
setMDMasking(Mantid::Geometry::MDImplicitFunction *maskingRegion) override;
void setMDMasking(std::unique_ptr<Mantid::Geometry::MDImplicitFunction>
maskingRegion) override;
/// Apply masking.
void setMDMaskAt(const size_t &index, bool mask);
......
......@@ -96,7 +96,7 @@ protected:
std::vector<specnum_t> m_monitorList;
/// A vector that holds the 1D histograms
std::vector<Histogram1D *> data;
std::vector<std::unique_ptr<Histogram1D>> data;
private:
Workspace2D *doClone() const override;
......
......@@ -147,9 +147,9 @@ bool BoxControllerNeXusIO::openFile(const std::string &fileName,
int nDims = static_cast<int>(this->m_bc->getNDims());
bool group_exists;
m_File = MDBoxFlatTree::createOrOpenMDWSgroup(
m_File = std::unique_ptr<::NeXus::File>(MDBoxFlatTree::createOrOpenMDWSgroup(
m_fileName, nDims, m_EventsTypesSupported[m_EventType], m_ReadOnly,
group_exists);
group_exists));
// we are in MD workspace Class group now
std::map<std::string, std::string> groupEntries;
......@@ -491,8 +491,6 @@ void BoxControllerNeXusIO::closeFile() {
m_File->closeGroup(); // close events group
m_File->closeGroup(); // close workspace group
m_File->close(); // close NeXus file
delete m_File;
m_File = nullptr;
}
}
......
......@@ -45,23 +45,21 @@ using std::size_t;
using namespace Mantid::Kernel;
EventWorkspace::EventWorkspace(const Parallel::StorageMode storageMode)
: IEventWorkspace(storageMode), mru(new EventWorkspaceMRU) {}
: IEventWorkspace(storageMode), mru(std::make_unique<EventWorkspaceMRU>()) {}
EventWorkspace::EventWorkspace(const EventWorkspace &other)
: IEventWorkspace(other), mru(new EventWorkspaceMRU) {
: IEventWorkspace(other), mru(std::make_unique<EventWorkspaceMRU>()) {
for (const auto &el : other.data) {
// Create a new event list, copying over the events
auto newel = new EventList(*el);
auto newel = std::make_unique<EventList>(*el);
// Make sure to update the MRU to point to THIS event workspace.
newel->setMRU(this->mru);
this->data.push_back(newel);
newel->setMRU(this->mru.get());
this->data.push_back(std::move(newel));
}
}
EventWorkspace::~EventWorkspace() {
for (auto &eventList : data)
delete eventList;
delete mru;
data.clear();
}
/** Returns true if the EventWorkspace is safe for multithreaded operations.
......@@ -100,20 +98,20 @@ void EventWorkspace::init(const std::size_t &NVectors,
HistogramData::BinEdges edges{0.0, std::numeric_limits<double>::min()};
// Initialize the data
data.resize(NVectors, nullptr);
data.resize(NVectors);
// Make sure SOMETHING exists for all initialized spots.
EventList el;
el.setHistogram(edges);
for (size_t i = 0; i < NVectors; i++) {
data[i] = new EventList(el);
data[i]->setMRU(mru);
data[i] = std::make_unique<EventList>(el);
data[i]->setMRU(mru.get());
data[i]->setSpectrumNo(specnum_t(i));
}
// Create axes.
m_axes.resize(2);
m_axes[0] = new API::RefAxis(this);
m_axes[1] = new API::SpectraAxis(this);
m_axes[0] = std::make_unique<API::RefAxis>(this);
m_axes[1] = std::make_unique<API::SpectraAxis>(this);
}
void EventWorkspace::init(const HistogramData::Histogram &histogram) {
......@@ -125,25 +123,25 @@ void EventWorkspace::init(const HistogramData::Histogram &histogram) {
throw std::runtime_error(
"EventWorkspace cannot be initialized non-NULL Y or E data");
data.resize(numberOfDetectorGroups(), nullptr);
data.resize(numberOfDetectorGroups());
EventList el;
el.setHistogram(histogram);
for (size_t i = 0; i < data.size(); i++) {
data[i] = new EventList(el);
data[i]->setMRU(mru);
data[i] = std::make_unique<EventList>(el);
data[i]->setMRU(mru.get());
data[i]->setSpectrumNo(specnum_t(i));
}
m_axes.resize(2);
m_axes[0] = new API::RefAxis(this);
m_axes[1] = new API::SpectraAxis(this);
m_axes[0] = std::make_unique<API::RefAxis>(this);
m_axes[1] = std::make_unique<API::SpectraAxis>(this);
}
/// The total size of the workspace
/// @returns the number of single indexable items in the workspace
size_t EventWorkspace::size() const {
return std::accumulate(data.begin(), data.end(), static_cast<size_t>(0),
[](size_t value, EventList *histo) {
[](size_t value, const std::unique_ptr<EventList> &histo) {
return value + histo->histogram_size();
});
}
......@@ -156,7 +154,7 @@ size_t EventWorkspace::blocksize() const {
"therefore cannot determine blocksize (# of bins).");
} else {
size_t numBins = data[0]->histogram_size();
for (const auto *iter : data)
for (const auto &iter : data)
if (numBins != iter->histogram_size())
throw std::length_error(
"blocksize undefined because size of histograms is not equal");
......@@ -405,7 +403,7 @@ void EventWorkspace::getEventXMinMax(double &xmin, double &xmax) const {
/// @returns The total number of events
size_t EventWorkspace::getNumberEvents() const {
return std::accumulate(data.begin(), data.end(), size_t{0},
[](size_t total, EventList *list) {
[](size_t total, auto &list) {
return total + list->getNumberEvents();
});
}
......@@ -416,7 +414,7 @@ size_t EventWorkspace::getNumberEvents() const {
*/
Mantid::API::EventType EventWorkspace::getEventType() const {
Mantid::API::EventType out = Mantid::API::TOF;
for (auto list : this->data) {
for (auto &list : this->data) {
Mantid::API::EventType thisType = list->getEventType();
if (static_cast<int>(out) < static_cast<int>(thisType)) {
out = thisType;
......@@ -457,7 +455,7 @@ size_t EventWorkspace::getMemorySize() const {
// Add the memory from all the event lists
size_t total = std::accumulate(data.begin(), data.end(), size_t{0},
[](size_t total, EventList *list) {
[](size_t total, auto &list) {
return total + list->getMemorySize();
});
......@@ -695,7 +693,7 @@ void EventWorkspace::getIntegratedSpectra(std::vector<double> &out,
for (int wksp_index = 0; wksp_index < int(this->getNumberHistograms());
wksp_index++) {
// Get Handle to data
EventList *el = this->data[wksp_index];
EventList *el = this->data[wksp_index].get();
// Let the eventList do the integration
out[wksp_index] = el->integrate(minX, maxX, entireRange);
......
......@@ -17,7 +17,6 @@ EventWorkspaceMRU::~EventWorkspaceMRU() {
for (auto &data : m_bufferedDataY) {
if (data) {
data->clear();
delete data;
}
}
}
......@@ -25,7 +24,6 @@ EventWorkspaceMRU::~EventWorkspaceMRU() {
for (auto &data : m_bufferedDataE) {
if (data) {
data->clear();
delete data;
}
}
}
......@@ -38,10 +36,10 @@ EventWorkspaceMRU::~EventWorkspaceMRU() {
void EventWorkspaceMRU::ensureEnoughBuffersE(size_t thread_num) const {
Poco::ScopedWriteRWLock _lock(m_changeMruListsMutexE);
if (m_bufferedDataE.size() <= thread_num) {
m_bufferedDataE.resize(thread_num + 1, nullptr);
m_bufferedDataE.resize(thread_num + 1);
for (auto &data : m_bufferedDataE) {
if (!data)
data = new mru_listE(50); // Create a MRU list with this many entries.
data = std::make_unique<mru_listE>(50); // Create a MRU list with this many entries.
}
}
}
......@@ -53,10 +51,10 @@ void EventWorkspaceMRU::ensureEnoughBuffersE(size_t thread_num) const {
void EventWorkspaceMRU::ensureEnoughBuffersY(size_t thread_num) const {
Poco::ScopedWriteRWLock _lock(m_changeMruListsMutexY);
if (m_bufferedDataY.size() <= thread_num) {
m_bufferedDataY.resize(thread_num + 1, nullptr);
m_bufferedDataY.resize(thread_num + 1);
for (auto &data : m_bufferedDataY) {
if (!data)
data = new mru_listY(50); // Create a MRU list with this many entries.
data = std::make_unique<mru_listY>(50); // Create a MRU list with this many entries.
}
}
}
......
......@@ -1292,7 +1292,7 @@ Does not perform any clearing. Multiple calls are compounded.
@param maskingRegion : Implicit function defining mask region.
*/
void MDHistoWorkspace::setMDMasking(
Mantid::Geometry::MDImplicitFunction *maskingRegion) {
std::unique_ptr<Mantid::Geometry::MDImplicitFunction> maskingRegion) {
if (maskingRegion != nullptr) {
for (size_t i = 0; i < this->getNPoints(); ++i) {
// If the function masks the point, then mask it, otherwise leave it as it
......@@ -1301,7 +1301,6 @@ void MDHistoWorkspace::setMDMasking(
this->setMDMaskAt(i, true);
}
}
delete maskingRegion;
}
}
......
......@@ -160,8 +160,8 @@ MantidVec createXAxis(MatrixWorkspace *const ws, const double gradX,
const double cxToUnit, const size_t nBins,
const std::string &caption, const std::string &units) {
// Create an X - Axis.
auto *const xAxis = new BinEdgeAxis(nBins);
ws->replaceAxis(0, xAxis);
auto xAxis = std::make_unique<BinEdgeAxis>(nBins);
ws->replaceAxis(0, std::move(xAxis));
auto unitXBasePtr = UnitFactory::Instance().create("Label");
boost::shared_ptr<Mantid::Kernel::Units::Label> xUnit =
boost::dynamic_pointer_cast<Mantid::Kernel::Units::Label>(unitXBasePtr);
......@@ -193,8 +193,8 @@ void createVerticalAxis(MatrixWorkspace *const ws, const MantidVec &xAxisVec,
const size_t nBins, const std::string &caption,
const std::string &units) {
// Create a Y (vertical) Axis
auto *const verticalAxis = new BinEdgeAxis(nBins);
ws->replaceAxis(1, verticalAxis);
auto verticalAxis = std::make_unique<BinEdgeAxis>(nBins);
ws->replaceAxis(1, std::move(verticalAxis));
auto unitZBasePtr = UnitFactory::Instance().create("Label");
boost::shared_ptr<Mantid::Kernel::Units::Label> verticalUnit =
boost::dynamic_pointer_cast<Mantid::Kernel::Units::Label>(unitZBasePtr);
......@@ -442,8 +442,8 @@ MatrixWorkspace_sptr ReflectometryTransform::executeNormPoly(
xBinsVec);
// Put the correct bin boundaries into the workspace
auto verticalAxis = new BinEdgeAxis(zBinsVec);
outWS->replaceAxis(1, verticalAxis);
auto verticalAxis = std::make_unique<BinEdgeAxis>(zBinsVec);
outWS->replaceAxis(1, std::move(verticalAxis));
HistogramData::BinEdges binEdges(xBinsVec);
for (size_t i = 0; i < zBinsVec.size() - 1; ++i)
outWS->setBinEdges(i, binEdges);
......
......@@ -33,31 +33,12 @@ Workspace2D::Workspace2D(const Workspace2D &other)
: HistoWorkspace(other), m_monitorList(other.m_monitorList) {
data.resize(other.data.size());
for (size_t i = 0; i < data.size(); ++i) {
data[i] = new Histogram1D(*(other.data[i]));
data[i] = std::make_unique<Histogram1D>(*