diff --git a/buildconfig/CMake/CppCheck_Suppressions.txt.in b/buildconfig/CMake/CppCheck_Suppressions.txt.in index 36fe47cfe509..83d072fc75cd 100644 --- a/buildconfig/CMake/CppCheck_Suppressions.txt.in +++ b/buildconfig/CMake/CppCheck_Suppressions.txt.in @@ -1123,7 +1123,7 @@ virtualCallInConstructor:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/ISISReflec missingOverride:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/ISISReflectometry/GUI/Save/SaveAlgorithmRunner.h:18 returnByReference:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.h:54 missingOverride:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/ISISReflectometry/Reduction/Group.h:31 -missingOverride:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/ISISReflectometry/Reduction/IGroup.h:18 +missingOverride:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/ISISReflectometry/Reduction/IGroup.h:19 returnByReference:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/ISISReflectometry/Reduction/TransmissionStitchOptions.h:34 returnByReference:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/Indirect/Reduction/ISISEnergyTransferData.h:42 returnByReference:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/Indirect/Reduction/ISISEnergyTransferData.h:43 diff --git a/qt/scientific_interfaces/ISISReflectometry/Common/IndexOf.h b/qt/scientific_interfaces/ISISReflectometry/Common/IndexOf.h index 473cf387595e..b20332571af8 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Common/IndexOf.h +++ b/qt/scientific_interfaces/ISISReflectometry/Common/IndexOf.h @@ -6,29 +6,29 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once #include -#include #include +#include namespace MantidQt { namespace CustomInterfaces { namespace ISISReflectometry { template -boost::optional indexOf(Container const &container, Predicate pred) { +std::optional indexOf(Container const &container, Predicate pred) { auto maybeItemIt = std::find_if(container.cbegin(), container.cend(), pred); if (maybeItemIt != container.cend()) return static_cast(std::distance(container.cbegin(), maybeItemIt)); else - return boost::none; + return std::nullopt; } template -boost::optional indexOfValue(Container const &container, ValueType value) { +std::optional indexOfValue(Container const &container, ValueType value) { auto maybeItemIt = std::find(container.cbegin(), container.cend(), value); if (maybeItemIt != container.cend()) return static_cast(std::distance(container.cbegin(), maybeItemIt)); else - return boost::none; + return std::nullopt; } } // namespace ISISReflectometry } // namespace CustomInterfaces diff --git a/qt/scientific_interfaces/ISISReflectometry/Common/Map.h b/qt/scientific_interfaces/ISISReflectometry/Common/Map.h index f30260b941df..f04ccaee66c3 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Common/Map.h +++ b/qt/scientific_interfaces/ISISReflectometry/Common/Map.h @@ -84,9 +84,9 @@ template std::string valueToString(T value, int precision) { * @return The value as a string (with specified precision if given) * */ -template std::string valueToString(T value, boost::optional precision) { - if (precision.is_initialized()) - return valueToString(value, precision.get()); +template std::string valueToString(T value, std::optional precision) { + if (precision.has_value()) + return valueToString(value, precision.value()); return std::to_string(value); } @@ -98,10 +98,10 @@ template std::string valueToString(T value, boost::optional pr * string * */ -template std::string optionalToString(boost::optional maybeValue, boost::optional precision) { +template std::string optionalToString(boost::optional maybeValue, std::optional precision) { if (maybeValue.is_initialized()) { - if (precision.is_initialized()) { - return valueToString(maybeValue.get(), precision.get()); + if (precision.has_value()) { + return valueToString(maybeValue.get(), precision.value()); } return optionalToString(maybeValue); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Decoder.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Decoder.cpp index f189dd3c012c..60606dae0fe3 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Decoder.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Decoder.cpp @@ -195,7 +195,7 @@ void Decoder::decodeInstrument(const QtInstrumentView *gui, const QMap &map, boost::optional precision, + const QMap &map, std::optional precision, QtCatalogSearcher *searcher) { decodeRunsTable(gui->m_tableView, redJobs, presenter, map[QString("runsTable")].toMap(), std::move(precision)); gui->m_ui.comboSearchInstrument->setCurrentIndex(map[QString("comboSearchInstrument")].toInt()); @@ -228,26 +228,23 @@ MantidWidgets::Batch::Cell qRangeCellOrDefault(RangeInQ const &qRangeInput, Rang return result; } -std::vector cellsFromRow(Row const &row, const boost::optional &precision) { - std::optional precisionStd = std::nullopt; - if (precision) - precisionStd = precision.get(); +std::vector cellsFromRow(Row const &row, const std::optional &precision) { return std::vector( {MantidQt::MantidWidgets::Batch::Cell(boost::join(row.runNumbers(), "+")), MantidQt::MantidWidgets::Batch::Cell(valueToString(row.theta(), precision)), MantidQt::MantidWidgets::Batch::Cell(row.transmissionWorkspaceNames().firstRunList()), MantidQt::MantidWidgets::Batch::Cell(row.transmissionWorkspaceNames().secondRunList()), - qRangeCellOrDefault(row.qRange(), row.qRangeOutput(), &RangeInQ::min, precisionStd), - qRangeCellOrDefault(row.qRange(), row.qRangeOutput(), &RangeInQ::max, precisionStd), - qRangeCellOrDefault(row.qRange(), row.qRangeOutput(), &RangeInQ::step, precisionStd), + qRangeCellOrDefault(row.qRange(), row.qRangeOutput(), &RangeInQ::min, precision), + qRangeCellOrDefault(row.qRange(), row.qRangeOutput(), &RangeInQ::max, precision), + qRangeCellOrDefault(row.qRange(), row.qRangeOutput(), &RangeInQ::step, precision), MantidQt::MantidWidgets::Batch::Cell(optionalToString(row.scaleFactor(), precision)), MantidQt::MantidWidgets::Batch::Cell(MantidWidgets::optionsToString(row.reductionOptions())), - MantidQt::MantidWidgets::Batch::Cell(optionalToString(row.lookupIndex(), precisionStd))}); + MantidQt::MantidWidgets::Batch::Cell(optionalToString(row.lookupIndex(), precision))}); } } // namespace void Decoder::updateRunsTableViewFromModel(QtRunsTableView *view, const ReductionJobs *model, - const boost::optional &precision) { + const std::optional &precision) { auto jobTreeView = view->m_jobs.get(); auto const &groups = model->groups(); for (auto groupIndex = 0u; groupIndex < groups.size(); ++groupIndex) { @@ -277,7 +274,7 @@ void Decoder::updateRunsTableViewFromModel(QtRunsTableView *view, const Reductio } void Decoder::decodeRunsTable(QtRunsTableView *gui, ReductionJobs *redJobs, RunsTablePresenter *presenter, - const QMap &map, boost::optional precision) { + const QMap &map, std::optional precision) { QSignalBlocker signalBlockerView(gui); m_projectSave = map[QString("projectSave")].toBool(); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Decoder.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Decoder.h index af5f0cb41d95..f4ef84217b49 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Decoder.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Common/Decoder.h @@ -65,9 +65,9 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL Decoder : public MantidQt::API::BaseDecoder void decodePerAngleDefaultsRows(QTableWidget *tab, int rowsNum, int columnsNum, const QList &list); void decodeInstrument(const QtInstrumentView *gui, const QMap &map); void decodeRuns(QtRunsView *gui, ReductionJobs *redJobs, RunsTablePresenter *presenter, - const QMap &map, boost::optional precision, QtCatalogSearcher *searcher); + const QMap &map, std::optional precision, QtCatalogSearcher *searcher); void decodeRunsTable(QtRunsTableView *gui, ReductionJobs *redJobs, RunsTablePresenter *presenter, - const QMap &map, boost::optional precision); + const QMap &map, std::optional precision); void decodeRunsTableModel(ReductionJobs *jobs, const QList &list); MantidQt::CustomInterfaces::ISISReflectometry::Group decodeGroup(const QMap &map); std::vector> @@ -81,7 +81,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL Decoder : public MantidQt::API::BaseDecoder void decodeSave(const QtSaveView *gui, const QMap &map); void decodeEvent(const QtEventView *gui, const QMap &map); void updateRunsTableViewFromModel(QtRunsTableView *view, const ReductionJobs *model, - const boost::optional &precision); + const std::optional &precision); bool m_projectSave = false; size_t m_currentBatchVersion = 0; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.cpp index a83f7c0da158..a989eb87da75 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.cpp @@ -441,9 +441,9 @@ void QtExperimentView::setText(QLineEdit &lineEdit, boost::optional valu setText(lineEdit, value.get()); } -void QtExperimentView::setText(QLineEdit &lineEdit, boost::optional value) { +void QtExperimentView::setText(QLineEdit &lineEdit, std::optional value) { if (value) - setText(lineEdit, value.get()); + setText(lineEdit, value.value()); } void QtExperimentView::setText(QLineEdit &lineEdit, boost::optional const &text) { diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.h index dfbb119be5ee..db45402fc743 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.h @@ -182,7 +182,7 @@ public slots: void setText(QLineEdit &lineEdit, int value); void setText(QLineEdit &lineEdit, double value); void setText(QLineEdit &lineEdit, std::string const &value); - void setText(QLineEdit &lineEdit, boost::optional value); + void setText(QLineEdit &lineEdit, std::optional value); void setText(QLineEdit &lineEdit, boost::optional value); void setText(QLineEdit &lineEdit, boost::optional const &value); std::string textFromCell(QTableWidgetItem const *maybeNullItem) const; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.cpp index c01689dd3696..b8cd0169f385 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.cpp @@ -183,9 +183,9 @@ void QtInstrumentView::setText(QLineEdit &lineEdit, boost::optional valu setText(lineEdit, value.get()); } -void QtInstrumentView::setText(QLineEdit &lineEdit, boost::optional value) { +void QtInstrumentView::setText(QLineEdit &lineEdit, std::optional value) { if (value) - setText(lineEdit, value.get()); + setText(lineEdit, value.value()); } void QtInstrumentView::setText(QLineEdit &lineEdit, boost::optional const &text) { diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.h index 174777de368b..aa5c38176c43 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.h @@ -98,7 +98,7 @@ public slots: void setText(QLineEdit &lineEdit, int value); void setText(QLineEdit &lineEdit, double value); void setText(QLineEdit &lineEdit, std::string const &value); - void setText(QLineEdit &lineEdit, boost::optional value); + void setText(QLineEdit &lineEdit, std::optional value); void setText(QLineEdit &lineEdit, boost::optional value); void setText(QLineEdit &lineEdit, boost::optional const &value); void setChecked(QCheckBox &checkBox, bool checked); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/IMainWindowPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/IMainWindowPresenter.h index 1f6eb340a877..74e2081522f7 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/IMainWindowPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/IMainWindowPresenter.h @@ -31,7 +31,7 @@ class IMainWindowPresenter { virtual bool isProcessPartialGroupPrevented() const = 0; virtual bool isRoundChecked() const = 0; virtual int &getRoundPrecision() const = 0; - virtual boost::optional roundPrecision() const = 0; + virtual std::optional roundPrecision() const = 0; virtual bool isCloseEventPrevented() = 0; virtual bool isCloseBatchPrevented(int batchIndex) const = 0; virtual bool isOverwriteBatchPrevented(int tabIndex) const = 0; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp index f56906567dc2..828a91cc9af9 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp @@ -180,10 +180,10 @@ int &MainWindowPresenter::getRoundPrecision() const { return m_optionsDialogPresenter->getIntOption(std::string("RoundPrecision")); } -boost::optional MainWindowPresenter::roundPrecision() const { +std::optional MainWindowPresenter::roundPrecision() const { if (isRoundChecked()) return getRoundPrecision(); - return boost::none; + return std::nullopt; } bool MainWindowPresenter::discardChanges(std::string const &message) const { @@ -268,12 +268,12 @@ void MainWindowPresenter::addNewBatch(IBatchView *batchView) { } void MainWindowPresenter::initNewBatch(IBatchPresenter *batchPresenter, std::string const &instrument, - boost::optional precision) { + std::optional precision) { batchPresenter->initInstrumentList(instrument); batchPresenter->notifyInstrumentChanged(instrument); - if (precision.is_initialized()) - batchPresenter->notifySetRoundPrecision(precision.get()); + if (precision.has_value()) + batchPresenter->notifySetRoundPrecision(precision.value()); // starts in the paused state batchPresenter->notifyReductionPaused(); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h index 80708c03a24f..db50443e61dc 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h @@ -99,7 +99,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL MainWindowPresenter : public MainWindowSubs bool isAnyBatchUnsaved() const override; bool isRoundChecked() const override; int &getRoundPrecision() const override; - boost::optional roundPrecision() const override; + std::optional roundPrecision() const override; bool isWarnProcessAllChecked() const override; bool isWarnProcessPartialGroupChecked() const override; bool isCloseBatchPrevented(int batchIndex) const override; @@ -108,7 +108,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL MainWindowPresenter : public MainWindowSubs void optionsChanged() const; void showHelp(); void addNewBatch(IBatchView *batchView); - void initNewBatch(IBatchPresenter *batchPresenter, std::string const &instrument, boost::optional precision); + void initNewBatch(IBatchPresenter *batchPresenter, std::string const &instrument, std::optional precision); void updateInstrument(const std::string &instrumentName); void setDefaultInstrument(const std::string &newInstrument); void onInstrumentChanged(); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/JobsViewUpdater.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/JobsViewUpdater.cpp index 2094b5a48427..8947f1d28bfb 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/JobsViewUpdater.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/JobsViewUpdater.cpp @@ -40,24 +40,19 @@ std::optional incrementIndex(const Row &row) { return lookupIndex.has_value() ? std::optional(lookupIndex.value() + 1) : std::nullopt; } -std::vector cellsFromRow(Row const &row, boost::optional precision) { - // convert type for precision - std::optional precisionStd = std::nullopt; - if (precision) - precisionStd = precision.get(); - +std::vector cellsFromRow(Row const &row, std::optional precision) { auto lookupIndex = incrementIndex(row); return std::vector( {MantidQt::MantidWidgets::Batch::Cell(boost::join(row.runNumbers(), "+")), MantidQt::MantidWidgets::Batch::Cell(valueToString(row.theta(), precision)), MantidQt::MantidWidgets::Batch::Cell(row.transmissionWorkspaceNames().firstRunList()), MantidQt::MantidWidgets::Batch::Cell(row.transmissionWorkspaceNames().secondRunList()), - qRangeCellOrDefault(row.qRange(), row.qRangeOutput(), &RangeInQ::min, precisionStd), - qRangeCellOrDefault(row.qRange(), row.qRangeOutput(), &RangeInQ::max, precisionStd), - qRangeCellOrDefault(row.qRange(), row.qRangeOutput(), &RangeInQ::step, precisionStd), + qRangeCellOrDefault(row.qRange(), row.qRangeOutput(), &RangeInQ::min, precision), + qRangeCellOrDefault(row.qRange(), row.qRangeOutput(), &RangeInQ::max, precision), + qRangeCellOrDefault(row.qRange(), row.qRangeOutput(), &RangeInQ::step, precision), MantidQt::MantidWidgets::Batch::Cell(optionalToString(row.scaleFactor(), precision)), MantidQt::MantidWidgets::Batch::Cell(MantidWidgets::optionsToString(row.reductionOptions())), - MantidQt::MantidWidgets::Batch::Cell(optionalToString(lookupIndex, precisionStd))}); + MantidQt::MantidWidgets::Batch::Cell(optionalToString(lookupIndex, precision))}); } } // namespace @@ -85,6 +80,6 @@ void JobsViewUpdater::rowModified(int groupIndex, int rowIndex, Row const &row) void JobsViewUpdater::setPrecision(const int &precision) { m_precision = precision; } -void JobsViewUpdater::resetPrecision() { m_precision = boost::none; } +void JobsViewUpdater::resetPrecision() { m_precision = std::nullopt; } } // namespace MantidQt::CustomInterfaces::ISISReflectometry diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/JobsViewUpdater.h b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/JobsViewUpdater.h index 80af24df37dc..351a5ee604d4 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/JobsViewUpdater.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/JobsViewUpdater.h @@ -32,7 +32,7 @@ class JobsViewUpdater { private: MantidQt::MantidWidgets::Batch::IJobTreeView &m_view; - boost::optional m_precision; + std::optional m_precision; }; } // namespace ISISReflectometry } // namespace CustomInterfaces diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/QtRunsTableView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/QtRunsTableView.cpp index f3788a8d2d63..560b9cce1c70 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/QtRunsTableView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/QtRunsTableView.cpp @@ -245,6 +245,6 @@ RunsTableViewFactory::RunsTableViewFactory(std::vector instruments) QtRunsTableView *RunsTableViewFactory::operator()() const { return new QtRunsTableView(m_instruments); } int RunsTableViewFactory::indexOfElseFirst(std::string const &instrument) const { - return indexOf(m_instruments, [&instrument](std::string const &inst) { return instrument == inst; }).get_value_or(0); + return indexOf(m_instruments, [&instrument](std::string const &inst) { return instrument == inst; }).value_or(0); } } // namespace MantidQt::CustomInterfaces::ISISReflectometry diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RunsTablePresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RunsTablePresenter.cpp index 994c1dd60071..323d2ef30dce 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RunsTablePresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RunsTablePresenter.cpp @@ -57,11 +57,11 @@ bool groupNameExists(std::string const &groupName, ReductionJobs const &jobs, // Check if the group name exists in the jobs auto maybeExistingGroupIndex = jobs.indexOfGroupWithName(groupName); - if (!maybeExistingGroupIndex.is_initialized()) + if (!maybeExistingGroupIndex.has_value()) return false; // If it exists but in one of the roots to ignore, return false - auto existingGroupLocation = MantidWidgets::Batch::RowLocation({maybeExistingGroupIndex.get()}); + auto existingGroupLocation = MantidWidgets::Batch::RowLocation({maybeExistingGroupIndex.value()}); if (std::find(rootsToIgnore.cbegin(), rootsToIgnore.cend(), existingGroupLocation) != rootsToIgnore.cend()) return false; diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/Group.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/Group.cpp index abc0706882aa..ae76a0fe5993 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/Group.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/Group.cpp @@ -91,7 +91,7 @@ bool Group::requiresPostprocessing(bool reprocessFailed) const { std::string Group::postprocessedWorkspaceName() const { return m_postprocessedWorkspaceName; } -boost::optional Group::indexOfRowWithTheta(double theta, double tolerance) const { +std::optional Group::indexOfRowWithTheta(double theta, double tolerance) const { return indexOf(m_rows, [theta, tolerance](boost::optional const &row) -> bool { return row.is_initialized() && std::abs(row.get().theta() - theta) < tolerance; }); diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/Group.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/Group.h index 79ab3e520f4c..5d09f1aaa57d 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/Group.h +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/Group.h @@ -72,7 +72,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL Group final : public IGroup { void resetSkipped() override; - boost::optional indexOfRowWithTheta(double angle, double tolerance) const override; + std::optional indexOfRowWithTheta(double angle, double tolerance) const override; boost::optional const &operator[](int rowIndex) const override; std::vector> const &rows() const override; @@ -103,8 +103,8 @@ void mergeRowsInto(Group &intoHere, Group const &fromHere, int groupIndex, doubl if (maybeRow.is_initialized()) { auto const &fromRow = maybeRow.get(); auto index = intoHere.indexOfRowWithTheta(fromRow.theta(), thetaTolerance); - if (index.is_initialized()) { - auto const updateAtIndex = index.get(); + if (index.has_value()) { + auto const updateAtIndex = index.value(); auto const &intoRow = intoHere[updateAtIndex].get(); auto updatedRow = mergedRow(intoRow, fromRow); intoHere.updateRow(updateAtIndex, updatedRow); diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/IGroup.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/IGroup.h index 0c39e4e6aa18..083711c7ec7e 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/IGroup.h +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/IGroup.h @@ -9,6 +9,7 @@ #include "Item.h" #include "Row.h" #include +#include #include #include @@ -32,7 +33,7 @@ class IGroup : public Item { virtual void resetSkipped() = 0; - virtual boost::optional indexOfRowWithTheta(double angle, double tolerance) const = 0; + virtual std::optional indexOfRowWithTheta(double angle, double tolerance) const = 0; virtual boost::optional const &operator[](int rowIndex) const = 0; virtual std::vector> const &rows() const = 0; diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.cpp index 7cec792dfed1..86aba6f2a765 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.cpp @@ -17,8 +17,8 @@ namespace MantidQt::CustomInterfaces::ISISReflectometry { namespace { Group &findOrMakeGroupWithName(ReductionJobs &jobs, std::string const &groupName) { auto maybeGroupIndex = jobs.indexOfGroupWithName(groupName); - if (maybeGroupIndex.is_initialized()) - return jobs.mutableGroups()[maybeGroupIndex.get()]; + if (maybeGroupIndex.has_value()) + return jobs.mutableGroups()[maybeGroupIndex.value()]; else return jobs.appendGroup(Group(groupName)); } @@ -44,7 +44,7 @@ Group &ReductionJobs::appendGroup(Group group) { return m_groups.back(); } -boost::optional ReductionJobs::indexOfGroupWithName(std::string const &groupName) const { +std::optional ReductionJobs::indexOfGroupWithName(std::string const &groupName) const { return indexOf(m_groups, [&groupName](Group const &group) -> bool { return group.name() == groupName; }); } @@ -148,11 +148,11 @@ void mergeRowIntoGroup(ReductionJobs &jobs, Row const &row, double thetaToleranc auto &group = findOrMakeGroupWithName(jobs, groupName); auto indexOfRowToUpdate = group.indexOfRowWithTheta(row.theta(), thetaTolerance); - if (indexOfRowToUpdate.is_initialized()) { - auto rowToUpdate = group[indexOfRowToUpdate.get()].get(); + if (indexOfRowToUpdate.has_value()) { + auto rowToUpdate = group[indexOfRowToUpdate.value()].get(); auto newRowValue = mergedRow(rowToUpdate, row); if (newRowValue.runNumbers() != rowToUpdate.runNumbers()) - group.updateRow(indexOfRowToUpdate.get(), newRowValue); + group.updateRow(indexOfRowToUpdate.value(), newRowValue); } else { group.insertRowSortedByAngle(row); } diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.h index f2cd3671ebf9..8bbddc43a623 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.h +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.h @@ -28,7 +28,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL ReductionJobs { Group &insertGroup(Group group, int beforeIndex); bool hasGroupWithName(std::string const &groupName) const; bool containsSingleEmptyGroup() const; - boost::optional indexOfGroupWithName(std::string const &groupName) const; + std::optional indexOfGroupWithName(std::string const &groupName) const; void removeGroup(int index); void removeAllGroups(); void resetState(); @@ -87,8 +87,8 @@ void mergeJobsInto(ReductionJobs &intoHere, ReductionJobs const &fromHere, doubl auto removeFirstGroup = intoHere.containsSingleEmptyGroup(); for (auto const &group : fromHere.groups()) { auto maybeGroupIndex = intoHere.indexOfGroupWithName(group.name()); - if (maybeGroupIndex.is_initialized()) { - auto indexToUpdateAt = maybeGroupIndex.get(); + if (maybeGroupIndex.has_value()) { + auto indexToUpdateAt = maybeGroupIndex.value(); auto &intoGroup = intoHere.mutableGroups()[indexToUpdateAt]; mergeRowsInto(intoGroup, group, indexToUpdateAt, thetaTolerance, listener); } else { diff --git a/qt/scientific_interfaces/ISISReflectometry/test/MainWindow/MockMainWindowPresenter.h b/qt/scientific_interfaces/ISISReflectometry/test/MainWindow/MockMainWindowPresenter.h index 3df3806510e5..d8d9d5a0cd87 100644 --- a/qt/scientific_interfaces/ISISReflectometry/test/MainWindow/MockMainWindowPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/test/MainWindow/MockMainWindowPresenter.h @@ -25,7 +25,7 @@ class MockMainWindowPresenter : public IMainWindowPresenter { MOCK_CONST_METHOD0(isWarnDiscardChangesChecked, bool()); MOCK_CONST_METHOD0(isRoundChecked, bool()); MOCK_CONST_METHOD0(getRoundPrecision, int &()); - MOCK_CONST_METHOD0(roundPrecision, boost::optional()); + MOCK_CONST_METHOD0(roundPrecision, std::optional()); MOCK_METHOD0(isCloseEventPrevented, bool()); MOCK_CONST_METHOD1(isCloseBatchPrevented, bool(int)); MOCK_CONST_METHOD1(isOverwriteBatchPrevented, bool(int)); diff --git a/qt/scientific_interfaces/ISISReflectometry/test/Reduction/GroupTest.h b/qt/scientific_interfaces/ISISReflectometry/test/Reduction/GroupTest.h index 9e128149807a..927cbfe0e7f4 100644 --- a/qt/scientific_interfaces/ISISReflectometry/test/Reduction/GroupTest.h +++ b/qt/scientific_interfaces/ISISReflectometry/test/Reduction/GroupTest.h @@ -498,23 +498,23 @@ class GroupTest : public CxxTest::TestSuite { void test_index_of_row_with_theta_exact_match() { auto group = makeGroupWithThreeRows(); auto maybeIndex = group.indexOfRowWithTheta(0.2, 0.01); - TS_ASSERT(maybeIndex.is_initialized()); - if (maybeIndex.is_initialized()) + TS_ASSERT(maybeIndex.has_value()); + if (maybeIndex.has_value()) TS_ASSERT_EQUALS(*maybeIndex, 1); } void test_index_of_row_with_theta_within_tolerance() { auto group = makeGroupWithThreeRows(); auto maybeIndex = group.indexOfRowWithTheta(0.209, 0.01); - TS_ASSERT(maybeIndex.is_initialized()); - if (maybeIndex.is_initialized()) + TS_ASSERT(maybeIndex.has_value()); + if (maybeIndex.has_value()) TS_ASSERT_EQUALS(*maybeIndex, 1); } void test_index_of_row_with_theta_outside_tolerance() { auto group = makeGroupWithThreeRows(); auto maybeIndex = group.indexOfRowWithTheta(0.23, 0.01); - TS_ASSERT(!maybeIndex.is_initialized()); + TS_ASSERT(!maybeIndex.has_value()); } void test_find_row_with_output_name() { diff --git a/qt/scientific_interfaces/ISISReflectometry/test/Reduction/MockGroup.h b/qt/scientific_interfaces/ISISReflectometry/test/Reduction/MockGroup.h index 6a822029a004..7c1c3ac77411 100644 --- a/qt/scientific_interfaces/ISISReflectometry/test/Reduction/MockGroup.h +++ b/qt/scientific_interfaces/ISISReflectometry/test/Reduction/MockGroup.h @@ -39,7 +39,7 @@ class MockGroup : public IGroup { MOCK_METHOD(void, resetSkipped, (), (override)); - MOCK_METHOD(boost::optional, indexOfRowWithTheta, (double, double), (const, override)); + MOCK_METHOD(std::optional, indexOfRowWithTheta, (double, double), (const, override)); MOCK_METHOD(boost::optional const &, bracketOp, (int), (const)); MOCK_METHOD(std::vector> const &, rows, (), (const, override));