Commit f5c7758f authored by Martyn Gigg's avatar Martyn Gigg Committed by Gigg, Martyn Anthony
Browse files

Replace features deleted in C++17

Removes binary_function/unary_function/ptr_fun.
parent d200a045
......@@ -163,20 +163,18 @@ FileFinderImpl::getInstrument(const string &hint) const {
} else {
// go forwards looking for the run number to start
{
string::const_iterator it = std::find_if(
instrName.begin(), instrName.end(), std::ptr_fun(isdigit));
std::string::size_type nChars = std::distance(
static_cast<string::const_iterator>(instrName.begin()), it);
const auto it =
std::find_if(instrName.begin(), instrName.end(), isdigit);
const auto nChars = std::distance(instrName.begin(), it);
instrName = instrName.substr(0, nChars);
}
// go backwards looking for the instrument name to end - gets around
// delimiters
if (!instrName.empty()) {
string::const_reverse_iterator it = std::find_if(
instrName.rbegin(), instrName.rend(), std::ptr_fun(isalpha));
string::size_type nChars = std::distance(
it, static_cast<string::const_reverse_iterator>(instrName.rend()));
const auto it =
std::find_if(instrName.rbegin(), instrName.rend(), isalpha);
const auto nChars = std::distance(it, instrName.rend());
instrName = instrName.substr(0, nChars);
}
}
......@@ -207,8 +205,8 @@ FileFinderImpl::toInstrumentAndNumber(const std::string &hint) const {
runPart = hint;
} else {
/// Find the last non-digit as the instrument name can contain numbers
std::string::const_reverse_iterator it = std::find_if(
hint.rbegin(), hint.rend(), std::not1(std::ptr_fun(isdigit)));
std::string::const_reverse_iterator it =
std::find_if(hint.rbegin(), hint.rend(), std::not_fn(isdigit));
// No non-digit or all non-digits
if (it == hint.rend() || it == hint.rbegin()) {
throw std::invalid_argument(
......
......@@ -252,16 +252,16 @@ bool groupnumber(std::string groupi, std::string groupj) {
int i = 0;
std::string groupName = groupi;
// Take out the "group" part of the group name and convert to an int
groupName.erase(remove_if(groupName.begin(), groupName.end(),
not1(std::ptr_fun(::isdigit))),
groupName.end());
groupName.erase(
remove_if(groupName.begin(), groupName.end(), std::not_fn(::isdigit)),
groupName.end());
Strings::convert(groupName, i);
int j = 0;
groupName = groupj;
// Take out the "group" part of the group name and convert to an int
groupName.erase(remove_if(groupName.begin(), groupName.end(),
not1(std::ptr_fun(::isdigit))),
groupName.end());
groupName.erase(
remove_if(groupName.begin(), groupName.end(), std::not_fn(::isdigit)),
groupName.end());
Strings::convert(groupName, j);
return (i < j);
}
......
......@@ -70,7 +70,7 @@ void Integration::init() {
* @return true if first argument < second argument (with some
* tolerance/epsilon)
*/
struct tolerant_less : public std::binary_function<double, double, bool> {
struct tolerant_less {
public:
bool operator()(const double &left, const double &right) const {
// soft equal, if the diff left-right is below a numerical error
......
......@@ -28,9 +28,7 @@ using Types::Core::DateAndTime;
Helper method to transform a MantidVector containing absolute times in
nanoseconds to relative times in seconds given an offset.
*/
class ConvertToRelativeTime
: public std::unary_function<const MantidVec::value_type &,
MantidVec::value_type> {
class ConvertToRelativeTime {
private:
double m_offSet;
......
......@@ -551,9 +551,9 @@ void AnvredCorrection::scale_exec(std::string &bankName, double &lambda,
double eff_R = 1.0 - exp(-mu * pathlength); // efficiency at point R
value *= eff_center / eff_R; // slant path efficiency ratio
// Take out the "bank" part of the bank name
bankName.erase(remove_if(bankName.begin(), bankName.end(),
not1(std::ptr_fun(::isdigit))),
bankName.end());
bankName.erase(
remove_if(bankName.begin(), bankName.end(), std::not_fn(::isdigit)),
bankName.end());
if (inst->hasParameter("detScale" + bankName))
value *=
static_cast<double>(inst->getNumberParameter("detScale" + bankName)[0]);
......
......@@ -366,9 +366,9 @@ void SaveHKL::exec() {
continue;
}
// Take out the "bank" part of the bank name and convert to an int
bankName.erase(remove_if(bankName.begin(), bankName.end(),
not1(std::ptr_fun(::isdigit))),
bankName.end());
bankName.erase(
remove_if(bankName.begin(), bankName.end(), std::not_fn(::isdigit)),
bankName.end());
Strings::convert(bankName, bank);
// Two-theta = polar angle = scattering angle = between +Z vector and
......
......@@ -194,9 +194,9 @@ void SaveLauenorm::exec() {
p.getRow() > (nRows - widthBorder)))
continue;
// Take out the "bank" part of the bank name and convert to an int
bankName.erase(remove_if(bankName.begin(), bankName.end(),
not1(std::ptr_fun(::isdigit))),
bankName.end());
bankName.erase(
remove_if(bankName.begin(), bankName.end(), std::not_fn(::isdigit)),
bankName.end());
if (type.compare(0, 2, "Ba") == 0) {
Strings::convert(bankName, sequence);
}
......@@ -270,9 +270,9 @@ void SaveLauenorm::exec() {
p.getRow() > (nRows - widthBorder)))
continue;
// Take out the "bank" part of the bank name and convert to an int
bankName.erase(remove_if(bankName.begin(), bankName.end(),
not1(std::ptr_fun(::isdigit))),
bankName.end());
bankName.erase(
remove_if(bankName.begin(), bankName.end(), std::not_fn(::isdigit)),
bankName.end());
if (type.compare(0, 2, "Ba") == 0) {
Strings::convert(bankName, sequence);
}
......
......@@ -958,11 +958,10 @@ void LeBailFit::parseInstrumentParametersTable() {
// string data
g_log.debug() << "Col-name = " << colname << ", ";
trow >> strvalue;
strvalue.erase(
std::find_if(strvalue.rbegin(), strvalue.rend(),
std::not1(std::ptr_fun<int, int>(std::isspace)))
.base(),
strvalue.end());
strvalue.erase(std::find_if(strvalue.rbegin(), strvalue.rend(),
std::not_fn(::isspace))
.base(),
strvalue.end());
g_log.debug() << "Value = " << strvalue << ".\n";
tempstrmap.emplace(colname, strvalue);
......
......@@ -63,9 +63,7 @@ int64_t calculateCorrectedFullTime(const EventType &event,
/**
* Type for comparing events in terms of time at sample
*/
template <typename EventType>
class CompareTimeAtSample
: public std::binary_function<EventType, EventType, bool> {
template <typename EventType> class CompareTimeAtSample {
private:
const double m_tofFactor;
const double m_tofShift;
......
......@@ -81,7 +81,7 @@ PeaksWorkspace::PeaksWorkspace(const PeaksWorkspace &other)
//=====================================================================================
/** Comparator class for sorting peaks by one or more criteria
*/
class PeakComparator : public std::binary_function<Peak, Peak, bool> {
class PeakComparator {
public:
std::vector<std::pair<std::string, bool>> &criteria;
......
......@@ -36,8 +36,7 @@ namespace MapSupport {
*/
// Note this needs to be non-constant unary_function return
template <typename T, typename U>
class PFirst : public std::unary_function<std::pair<T, U>, T> {
template <typename T, typename U> class PFirst {
public:
/// Functional to the first object
T operator()(const std::pair<T, U> &A) { return A.first; }
......@@ -51,8 +50,7 @@ public:
\brief Class to access the second object in index pair.
*/
template <typename T, typename U>
class PSecond : public std::unary_function<std::pair<T, U>, U> {
template <typename T, typename U> class PSecond {
public:
/// Functional to the first object
U operator()(const std::pair<T, U> &A) { return A.second; }
......@@ -134,9 +132,7 @@ public:
This functor swaps the components in a map.
*/
template <typename KeyPart, typename BodyPart>
class mapSwap : public std::unary_function<std::pair<BodyPart, KeyPart>,
std::pair<KeyPart, BodyPart>> {
template <typename KeyPart, typename BodyPart> class mapSwap {
public:
/// Operator()
std::pair<BodyPart, KeyPart>
......@@ -180,9 +176,7 @@ public:
key not found.
*/
template <typename KeyPart, typename NumPart>
class sndValue
: public std::unary_function<std::map<KeyPart, NumPart>, NumPart> {
template <typename KeyPart, typename NumPart> class sndValue {
private:
const std::map<KeyPart, NumPart> &MRef; ///< Map begin accessd
......
......@@ -19,24 +19,20 @@
namespace Mantid {
namespace Geometry {
/// Helper unary comparison type for finding IMDDimensions by a specified id.
struct findID
: public std::unary_function<Mantid::Geometry::IMDDimension_sptr, bool> {
struct findID {
const std::string m_id;
explicit findID(const std::string &id) : m_id(id) {}
bool operator()(const Mantid::Geometry::IMDDimension_sptr obj) const {
return m_id == obj->getDimensionId();
}
findID &operator=(const findID &);
};
/// Helper unary comparison type for finding non-integrated dimensions.
struct findIntegrated
: public std::unary_function<Mantid::Geometry::IMDDimension_sptr, bool> {
struct findIntegrated {
bool operator()(const Mantid::Geometry::IMDDimension_sptr obj) const {
return obj->getIsIntegrated();
}
findIntegrated &operator=(const findIntegrated &);
};
/**
......@@ -254,7 +250,7 @@ MDGeometryXMLParser::getIntegratedDimensions() const {
validate();
Mantid::Geometry::VecIMDDimension_sptr temp = m_vecAllDims;
temp.erase(
std::remove_if(temp.begin(), temp.end(), std::not1(findIntegrated())),
std::remove_if(temp.begin(), temp.end(), std::not_fn(findIntegrated())),
temp.end());
return temp;
}
......
......@@ -214,8 +214,8 @@ Complementary subtraction is by making A-B == A*B'
// Have DNF parts and will return the same...
// Sort the components of the list
std::for_each(Fparts.begin(), Fparts.end(), std::mem_fun_ref(&Acomp::Sort));
std::for_each(Gparts.begin(), Gparts.end(), std::mem_fun_ref(&Acomp::Sort));
std::for_each(Fparts.begin(), Fparts.end(), std::mem_fn(&Acomp::Sort));
std::for_each(Gparts.begin(), Gparts.end(), std::mem_fn(&Acomp::Sort));
// Sort the list itself...
std::sort(Gparts.begin(), Gparts.end());
......@@ -603,7 +603,7 @@ Decends down the Comp Tree.
{
std::sort(Units.begin(), Units.end());
// Sort each decending object first
std::for_each(Comp.begin(), Comp.end(), std::mem_fun_ref(&Acomp::Sort));
std::for_each(Comp.begin(), Comp.end(), std::mem_fn(&Acomp::Sort));
// use the sorted components to sort our component list
std::sort(Comp.begin(), Comp.end());
}
......@@ -756,9 +756,6 @@ literals
for (cc = Comp.begin(); cc != Comp.end(); ++cc) {
cc->getLiterals(literalMap);
}
// Doesn't work because literal map is a reference
// for_each(Comp.begin(),Comp.end(),
// std::bind2nd(std::mem_fun(&Acomp::getLiterals), literalMap));
}
int Acomp::isSimple() const
......@@ -838,7 +835,7 @@ i.e. one pass.
// set PI status to 1
using std::placeholders::_1;
for_each(Work.begin(), Work.end(),
std::bind(std::mem_fun_ref(&BnId::setPI), _1, 1));
std::bind(std::mem_fn(&BnId::setPI), _1, 1));
// Collect into pairs which have a difference of +/- one
// object
......@@ -1522,7 +1519,7 @@ ab -> a'+b'
std::bind(std::multiplies<int>(), _1, -1));
sort(Units.begin(), Units.end()); /// Resort the list. use reverse?
for_each(Comp.begin(), Comp.end(), std::mem_fun_ref(&Acomp::complement));
for_each(Comp.begin(), Comp.end(), std::mem_fn(&Acomp::complement));
sort(Comp.begin(), Comp.end());
}
......
......@@ -881,7 +881,7 @@ std::vector<int> CSGObject::getSurfaceIndex() const {
std::vector<int> out;
transform(m_SurList.begin(), m_SurList.end(),
std::insert_iterator<std::vector<int>>(out, out.begin()),
std::mem_fun(&Surface::getName));
std::mem_fn(&Surface::getName));
return out;
}
......
......@@ -12,10 +12,7 @@
//----------------------------------------------------------------------
#include "MantidKernel/DllConfig.h"
#ifndef Q_MOC_RUN
#include <boost/scoped_ptr.hpp>
#endif
#include <memory>
#include <vector>
namespace Mantid {
......
......@@ -163,7 +163,7 @@ template <typename T> std::vector<T> normalizeVector(const std::vector<T> &x) {
/// Functor used for computing the sum of the square values of a vector, using
/// the accumulate algorithm
template <class T> struct SumGaussError : public std::binary_function<T, T, T> {
template <class T> struct SumGaussError {
SumGaussError() = default;
/// Sums the arguments in quadrature
inline T operator()(const T &l, const T &r) const {
......@@ -177,7 +177,7 @@ template <class T> struct SumGaussError : public std::binary_function<T, T, T> {
* More generally add errors in quadrature using the square of one of the errors
* (variance = error^2)
*/
template <class T> struct AddVariance : public std::binary_function<T, T, T> {
template <class T> struct AddVariance {
AddVariance() = default;
/// adds the square of the left-hand argument to the right hand argument and
/// takes the square root
......@@ -185,28 +185,28 @@ template <class T> struct AddVariance : public std::binary_function<T, T, T> {
};
/// Functor to accumulate a sum of squares
template <class T> struct SumSquares : public std::binary_function<T, T, T> {
template <class T> struct SumSquares {
SumSquares() = default;
/// Adds the square of the right-hand argument to the left hand one
T operator()(const T &r, const T &x) const { return (r + x * x); }
};
/// Functor giving the product of the squares of the arguments
template <class T> struct TimesSquares : public std::binary_function<T, T, T> {
template <class T> struct TimesSquares {
TimesSquares() = default;
/// Multiplies the squares of the arguments
T operator()(const T &l, const T &r) const { return (r * r * l * l); }
};
/// Square functor
template <class T> struct Squares : public std::unary_function<T, T> {
template <class T> struct Squares {
Squares() = default;
/// Returns the square of the argument
T operator()(const T &x) const { return (x * x); }
};
/// Log functor
template <class T> struct Log : public std::unary_function<T, T> {
template <class T> struct Log {
Log() = default;
/// Returns the logarithm of the argument
/// @throws std::range_error if x <= 0
......@@ -219,15 +219,14 @@ template <class T> struct Log : public std::unary_function<T, T> {
};
// Non-throwing version of the Log functor
template <class T> struct LogNoThrow : public std::unary_function<T, T> {
template <class T> struct LogNoThrow {
LogNoThrow() = default;
// Returns the logarithm of the argument
T operator()(const T &x) const { return std::log(x); }
};
/// Divide functor with result reset to 0 if the denominator is null
template <class T>
struct DividesNonNull : public std::binary_function<T, T, T> {
template <class T> struct DividesNonNull {
DividesNonNull() = default;
/// Returns l/r if r is non-zero, otherwise returns l.
T operator()(const T &l, const T &r) const {
......@@ -238,7 +237,7 @@ struct DividesNonNull : public std::binary_function<T, T, T> {
};
/// A binary functor to compute the simple average of 2 numbers
template <class T> struct SimpleAverage : public std::binary_function<T, T, T> {
template <class T> struct SimpleAverage {
SimpleAverage() = default;
/// Return the average of the two arguments
T operator()(const T &x, const T &y) const {
......
......@@ -20,7 +20,7 @@ namespace MDAlgorithms {
/**
Helper type to compute the square in-place.
*/
struct Square : public std::unary_function<double, void> {
struct Square {
void operator()(double &i) { i *= i; }
};
......
......@@ -29,7 +29,7 @@ namespace MDAlgorithms {
/**
Functor to compute the product of the set.
*/
struct Product : public std::unary_function<size_t, void> {
struct Product {
Product() : result(1) {}
size_t result;
void operator()(size_t x) { result *= x; }
......
......@@ -55,8 +55,7 @@ struct InputArgument {
};
/// Comparator to allow sorting by dimension index.
struct LessThanIndex
: std::binary_function<InputArgument, InputArgument, bool> {
struct LessThanIndex {
bool operator()(const InputArgument &a, const InputArgument &b) const {
return a.index < b.index;
}
......
......@@ -31,7 +31,7 @@ namespace {
/// Functor used for computing the sum of the square values of a vector
// Used by the eplus templates below
template <class T> struct SumGaussError : public std::binary_function<T, T, T> {
template <class T> struct SumGaussError {
SumGaussError() {}
/// Sums the arguments in quadrature
inline T operator()(const T &l, const T &r) const {
......
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