diff --git a/common/ParameterSet.h b/common/ParameterSet.h index 7b6b011250fcca84443eb82e9665c2f92b137f60..4b585d136d05644dd953a9aa9835c0752152b55a 100644 --- a/common/ParameterSet.h +++ b/common/ParameterSet.h @@ -293,6 +293,20 @@ class ParameterSet { std::vector<uint64_t> getUint64Vector(const std::string& aKey, const std::vector<uint64_t>& aValue, bool expandable = false) const; + std::vector<size_t> getSizeTVector(const std::string& aKey, + bool expandable = false) const { + static_assert(sizeof(size_t) == 8 || sizeof(size_t) == 4); + // Lambda is necessary because returning the wrong type won't compile in the + // main function, even when inside a if constexpr. + auto pick_overload = [&](const std::string& aKey, bool expandable = false) { + if constexpr (sizeof(size_t) == 8) { + return getUint64Vector(aKey, expandable); + } else if constexpr (sizeof(size_t) == 4) { + return getUint32Vector(aKey, expandable); + } + }; + return pick_overload(aKey, expandable); + } std::vector<float> getFloatVector(const std::string& aKey, bool expandable = false) const; std::vector<float> getFloatVector(const std::string& aKey, diff --git a/external/aocommon b/external/aocommon index ea534da2fda4ec24329c5ca2bbee344f42806546..e34551baf386a9f7c908bef7b30e0ce6194174b8 160000 --- a/external/aocommon +++ b/external/aocommon @@ -1 +1 @@ -Subproject commit ea534da2fda4ec24329c5ca2bbee344f42806546 +Subproject commit e34551baf386a9f7c908bef7b30e0ce6194174b8 diff --git a/steps/DDECal.cc b/steps/DDECal.cc index 3575f46b27e99373d69ea3ff4d7d1c4115261f32..538e24db109750c030c1ab5dd36253c13a4b3b2f 100644 --- a/steps/DDECal.cc +++ b/steps/DDECal.cc @@ -90,7 +90,7 @@ DDECal::DDECal(const common::ParameterSet& parset, const std::string& prefix) if (parset.isDefined(prefix + "solutions_per_direction")) { itsSolutionsPerDirection = - parset.getUint64Vector(prefix + "solutions_per_direction"); + parset.getSizeTVector(prefix + "solutions_per_direction"); } if (itsSolutionsPerDirection.size() > itsDirections.size()) { diff --git a/steps/test/unit/tApplyCalH5.cc b/steps/test/unit/tApplyCalH5.cc index 3b875078617e1653b77bde7fb15b19f1dacabca9..6689df5633f43b7fe21c34791fe8a26866cf89df 100644 --- a/steps/test/unit/tApplyCalH5.cc +++ b/steps/test/unit/tApplyCalH5.cc @@ -21,7 +21,6 @@ #include "../../../common/StringTools.h" #include "../../../common/StreamUtil.h" -using casacore::max; using dp3::base::DPBuffer; using dp3::base::DPInfo; using dp3::common::ParameterSet; @@ -361,13 +360,13 @@ void createH5Parm(std::vector<double> times, std::vector<double> freqs, soltab.SetFreqs(freqs); soltab.SetAntennas(antNames); - unsigned int ntimes = max(times.size(), 1); - unsigned int nfreqs = max(freqs.size(), 1); + const size_t ntimes = std::max<size_t>(times.size(), 1u); + const size_t nfreqs = std::max<size_t>(freqs.size(), 1u); std::vector<double> values(ntimes * nfreqs * nAntennas); std::vector<double> weights(ntimes * nfreqs * nAntennas); - for (unsigned int ant = 0; ant < nAntennas; ++ant) { - for (unsigned int t = 0; t < ntimes; ++t) { - for (unsigned int f = 0; f < nfreqs; ++f) { + for (size_t ant = 0; ant < nAntennas; ++ant) { + for (size_t t = 0; t < ntimes; ++t) { + for (size_t f = 0; f < nfreqs; ++f) { values[ant * ntimes * nfreqs + t * nfreqs + f] = 1. / (100. * (t % 100) + (1 + f)); weights[ant * ntimes * nfreqs + t * nfreqs + f] = 1.;