Skip to content

Commit 54b44b2

Browse files
Merge pull request #37838 from mantidproject/cpp_20
Update to C++ 20 standard
2 parents 6018a76 + 4f1d532 commit 54b44b2

File tree

46 files changed

+125
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+125
-128
lines changed

Framework/API/inc/MantidAPI/NumericAxis.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class MANTID_API_DLL NumericAxis : public Axis {
4141
/// Set the value at a specific index
4242
void setValue(const std::size_t &index, const double &value) override;
4343
size_t indexOfValue(const double value) const override;
44+
bool operator==(const NumericAxis &) const;
4445
bool operator==(const Axis &) const override;
4546
virtual bool equalWithinTolerance(const Axis &axis2, const double tolerance) const;
4647
std::string label(const std::size_t &index) const override;

Framework/API/inc/MantidAPI/TextAxis.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class MANTID_API_DLL TextAxis : public Axis {
4747
void setValue(const std::size_t &index, const double &value) override;
4848
size_t indexOfValue(const double value) const override;
4949

50+
bool operator==(const TextAxis &) const;
5051
bool operator==(const Axis &) const override;
5152
/// Get the label at the specified index
5253
std::string label(const std::size_t &index) const override;
@@ -60,6 +61,7 @@ class MANTID_API_DLL TextAxis : public Axis {
6061
private:
6162
/// A vector holding the axis values for the axis.
6263
std::vector<std::string> m_values;
64+
bool compareToTextAxis(const TextAxis &axis2) const;
6365
};
6466

6567
} // namespace API

Framework/API/src/CompositeFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace Mantid::API {
2727
namespace {
2828
/// static logger
2929
Kernel::Logger g_log("CompositeFunction");
30-
constexpr char *ATTNUMDERIV = "NumDeriv";
30+
constexpr const char *ATTNUMDERIV = "NumDeriv";
3131
constexpr int NUMDEFAULTATTRIBUTES = 1;
3232
/**
3333
* Helper function called when we replace a function within the composite

Framework/API/src/NotebookBuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "MantidAPI/HistoryItem.h"
1313
#include "MantidKernel/Logger.h"
1414
#include "MantidKernel/Property.h"
15+
#include "MantidKernel/WarningSuppressions.h"
1516

1617
#include <boost/utility.hpp>
1718
#include <utility>
@@ -143,6 +144,8 @@ const std::string NotebookBuilder::buildAlgorithmString(const AlgorithmHistory_c
143144
return name + "(" + propStr + ")";
144145
}
145146

147+
GNU_DIAG_OFF("maybe-uninitialized")
148+
146149
/**
147150
* Build the script output for a single property
148151
*
@@ -182,4 +185,6 @@ const std::string NotebookBuilder::buildPropertyString(const PropertyHistory_con
182185
return prop;
183186
}
184187

188+
GNU_DIAG_ON("maybe-uninitialized")
189+
185190
} // namespace Mantid::API

Framework/API/src/NumericAxis.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ void NumericAxis::setValue(const std::size_t &index, const double &value) {
107107
m_values[index] = value;
108108
}
109109

110+
/** Check if two NumericAxis are equivalent
111+
* @param axis2 :: Reference to the axis to compare to
112+
* @return true if self and second axis are equal
113+
*/
114+
bool NumericAxis::operator==(const NumericAxis &axis2) const { return equalWithinTolerance(axis2, 1e-15); }
115+
110116
/** Check if two axis defined as spectra or numeric axis are equivalent
111117
* @param axis2 :: Reference to the axis to compare to
112118
* @return true if self and second axis are equal

Framework/API/src/ScriptBuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "MantidKernel/Logger.h"
1818
#include "MantidKernel/Property.h"
1919
#include "MantidKernel/PropertyHistory.h"
20+
#include "MantidKernel/WarningSuppressions.h"
2021

2122
#include <boost/algorithm/string/classification.hpp>
2223
#include <boost/range/algorithm/remove_if.hpp>
@@ -260,6 +261,8 @@ const std::string ScriptBuilder::buildAlgorithmString(const AlgorithmHistory &al
260261
return historyEntry;
261262
}
262263

264+
GNU_DIAG_OFF("maybe-uninitialized")
265+
263266
/**
264267
* Build the script output for a single property
265268
*
@@ -316,4 +319,6 @@ const std::string ScriptBuilder::buildPropertyString(const Mantid::Kernel::Prope
316319
return prop;
317320
}
318321

322+
GNU_DIAG_ON("maybe-uninitialized")
323+
319324
} // namespace Mantid::API

Framework/API/src/TextAxis.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,29 @@ size_t TextAxis::indexOfValue(const double value) const {
7474
return Mantid::Kernel::VectorHelper::indexOfValueFromCenters(spectraNumbers, value);
7575
}
7676

77-
/** Check if two axis defined as spectra or numeric axis are equivalent
77+
/** Check if two TextAxis are equivalent
7878
* @param axis2 :: Reference to the axis to compare to
7979
* @return true if self and other axis are equal
8080
*/
81-
bool TextAxis::operator==(const Axis &axis2) const {
81+
bool TextAxis::operator==(const TextAxis &axis2) const { return compareToTextAxis(axis2); }
82+
83+
bool TextAxis::compareToTextAxis(const TextAxis &axis2) const {
8284
if (length() != axis2.length()) {
8385
return false;
8486
}
87+
return std::equal(m_values.begin(), m_values.end(), axis2.m_values.begin());
88+
}
89+
90+
/** Check if two axis defined as spectra or numeric axis are equivalent
91+
* @param axis2 :: Reference to the axis to compare to
92+
* @return true if self and other axis are equal
93+
*/
94+
bool TextAxis::operator==(const Axis &axis2) const {
8595
const auto *spec2 = dynamic_cast<const TextAxis *>(&axis2);
8696
if (!spec2) {
8797
return false;
8898
}
89-
return std::equal(m_values.begin(), m_values.end(), spec2->m_values.begin());
99+
return compareToTextAxis(*spec2);
90100
}
91101

92102
/** Returns a text label which shows the value at index and identifies the

Framework/API/test/MDFrameValidatorTest.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ class MDFrameValidatorTest : public CxxTest::TestSuite {
3030
static void destroySuite(MDFrameValidatorTest *suite) { delete suite; }
3131

3232
void testGetType() {
33-
MDFrameValidator unitValidator(HKL::HKLName);
33+
MDFrameValidator unitValidator(Mantid::Geometry::HKL::HKLName);
3434
TS_ASSERT_EQUALS(unitValidator.getType(), "mdframe");
3535
}
3636

3737
void testHKLMDWorkspaceIsValidForValidatorWithHKLFrame() {
38-
MDFrameValidator frameValidator(HKL::HKLName);
38+
MDFrameValidator frameValidator(Mantid::Geometry::HKL::HKLName);
3939

4040
HKLFrameFactory factory;
41-
auto frame = factory.create(MDFrameArgument{HKL::HKLName, Units::Symbol::RLU});
41+
auto frame = factory.create(MDFrameArgument{Mantid::Geometry::HKL::HKLName, Units::Symbol::RLU});
4242
auto dim = std::make_shared<MDHistoDimension>("x", "x", *frame, 0.0f, 100.0f, 10);
4343
auto ws = std::make_shared<MDHistoWorkspaceTester>(dim, dim, dim);
4444
TS_ASSERT_EQUALS(frameValidator.isValid(ws), "")
@@ -47,7 +47,7 @@ class MDFrameValidatorTest : public CxxTest::TestSuite {
4747
void testHKLMDWorkspaceIsNotValidForValidatorWithQLabFrame() {
4848
MDFrameValidator frameValidator(QLab::QLabName);
4949

50-
MDFrameArgument args{HKL::HKLName, Units::Symbol::RLU};
50+
MDFrameArgument args{Mantid::Geometry::HKL::HKLName, Units::Symbol::RLU};
5151
auto frame = HKLFrameFactory().create(args);
5252
auto dim = std::make_shared<MDHistoDimension>("x", "x", *frame, 0.0f, 100.0f, 10);
5353
auto ws = std::make_shared<MDHistoWorkspaceTester>(dim, dim, dim);
@@ -57,7 +57,7 @@ class MDFrameValidatorTest : public CxxTest::TestSuite {
5757
void testMixedAxisMDWorkspaceIsNotValidForValidatorWithQLabFrame() {
5858
MDFrameValidator frameValidator(QLab::QLabName);
5959

60-
MDFrameArgument axisArgs1{HKL::HKLName, Units::Symbol::RLU};
60+
MDFrameArgument axisArgs1{Mantid::Geometry::HKL::HKLName, Units::Symbol::RLU};
6161
MDFrameArgument axisArgs2{QLab::QLabName, Units::Symbol::InverseAngstrom};
6262

6363
auto frame1 = HKLFrameFactory().create(axisArgs1);

Framework/Algorithms/src/SampleCorrections/MayersSampleCorrection.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ Kernel::IValidator_sptr MayersSampleCorrection::createInputWSValidator() const {
166166
using Kernel::CompositeValidator;
167167
auto validator = std::make_shared<CompositeValidator>();
168168

169-
unsigned int requires = (InstrumentValidator::SamplePosition | InstrumentValidator::SourcePosition);
170-
validator->add<InstrumentValidator, unsigned int>(requires);
169+
unsigned int require = (InstrumentValidator::SamplePosition | InstrumentValidator::SourcePosition);
170+
validator->add<InstrumentValidator, unsigned int>(require);
171171

172-
requires = (SampleValidator::Shape | SampleValidator::Material);
173-
validator->add<SampleValidator, unsigned int>(requires);
172+
require = (SampleValidator::Shape | SampleValidator::Material);
173+
validator->add<SampleValidator, unsigned int>(require);
174174

175175
// NOTE: Mayers correction requires the input to be of TOF
176176
validator->add<WorkspaceUnitValidator>("TOF");

Framework/Crystal/test/FindClusterFacesTest.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ class FindClusterFacesTest : public CxxTest::TestSuite {
110110

111111
private:
112112
void verify_table_row(ITableWorkspace_sptr &outWS, int expectedClusterId, double expectedWorkspaceIndex,
113-
int expectedNormalDimensionIndex, bool expectedMaxExtent, double expectedRadius = -1) {
113+
int expectedNormalDimensionIndex, Mantid::API::Boolean expectedMaxExtent,
114+
double expectedRadius = -1) {
114115
for (size_t rowIndex = 0; rowIndex < outWS->rowCount(); ++rowIndex) {
115116
auto clusterId = outWS->cell<int>(rowIndex, 0);
116117
auto wsIndex = outWS->cell<double>(rowIndex, 1);

0 commit comments

Comments
 (0)