Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-39700: Remove inheritance from unary/binary_function #691

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/lsst/afw/image/Pixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ struct exprTraits<unsigned short> {

/// A noop functor (useful for e.g. masks and variances when changing the sign of the image)
template <typename T1>
struct noop : public std::unary_function<T1, T1> {
struct noop {
T1 operator()(const T1& x) const { return x; }
};

Expand All @@ -345,7 +345,7 @@ struct noop : public std::unary_function<T1, T1> {
* masked pixel,
*/
template <typename T1>
struct bitwise_or : public std::binary_function<T1, T1, T1> {
struct bitwise_or {
T1 operator()(const T1& x, const T1& y) const { return (x | y); }
T1 operator()(const T1& x) const { return x; }
};
Expand Down
19 changes: 7 additions & 12 deletions include/lsst/afw/image/lsstGil.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ BOOST_GIL_DEFINE_BASE_TYPEDEFS(32f_noscale, bits32f_noscale, gray)
BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f_noscale, bits32f_noscale, dev2n, devicen_t<2>, devicen_layout_t<2>)

template <>
struct channel_multiplier<bits32f_noscale>
: public std::binary_function<bits32f_noscale, bits32f_noscale, bits32f_noscale> {
struct channel_multiplier<bits32f_noscale> {
bits32f_noscale operator()(bits32f_noscale a, bits32f_noscale b) const { return a * b; }
};

Expand All @@ -144,26 +143,22 @@ BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(64f_noscale, bits64f_noscale, dev2n, devi
// Conversions that don't scale
//
template <typename DstChannelV>
struct channel_converter<bits32f_noscale, DstChannelV>
: public std::unary_function<bits32f_noscale, DstChannelV> {
struct channel_converter<bits32f_noscale, DstChannelV> {
DstChannelV operator()(bits32f_noscale x) const { return DstChannelV(x + 0.5f); }
};

template <typename SrcChannelV>
struct channel_converter<SrcChannelV, bits32f_noscale>
: public std::unary_function<SrcChannelV, bits32f_noscale> {
struct channel_converter<SrcChannelV, bits32f_noscale> {
bits32f_noscale operator()(SrcChannelV x) const { return bits32f_noscale(x); }
};

template <typename DstChannelV>
struct channel_converter<bits64f_noscale, DstChannelV>
: public std::unary_function<bits64f_noscale, DstChannelV> {
struct channel_converter<bits64f_noscale, DstChannelV> {
DstChannelV operator()(bits64f_noscale x) const { return DstChannelV(x + 0.5f); }
};

template <typename SrcChannelV>
struct channel_converter<SrcChannelV, bits64f_noscale>
: public std::unary_function<SrcChannelV, bits64f_noscale> {
struct channel_converter<SrcChannelV, bits64f_noscale> {
bits64f_noscale operator()(SrcChannelV x) const { return bits64f_noscale(x); }
};

Expand All @@ -172,12 +167,12 @@ struct channel_converter<SrcChannelV, bits64f_noscale>
//
#define LSST_CONVERT_NOOP(T1, T2) \
template <> \
struct channel_converter<T1, T2> : public std::unary_function<T1, T2> { \
struct channel_converter<T1, T2> { \
T2 operator()(T1 x) const { return static_cast<T2>(x); } \
}; \
\
template <> \
struct channel_converter<T2, T1> : public std::unary_function<T2, T1> { \
struct channel_converter<T2, T1> { \
T1 operator()(T2 x) const { return static_cast<T1>(x); } \
}

Expand Down
10 changes: 4 additions & 6 deletions include/lsst/afw/math/Integrate.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ AuxFunc2<UF> inline Aux2(UF uf) {

// pulled from MoreFunctional.h. Needed in class Int2DAuxType and Int3DAuxType
template <class BF>
class binder2_1 : public std::unary_function<typename BF::second_argument_type, typename BF::result_type> {
class binder2_1 {
public:
binder2_1(const BF &oper, typename BF::first_argument_type val) : _oper(oper), _value(val) {}
typename BF::result_type operator()(const typename BF::second_argument_type &x) const {
Expand All @@ -631,7 +631,7 @@ inline binder2_1<BF> bind21(const BF &oper, const Tp &x) {
}

template <class BF, class YREG>
class Int2DAuxType : public std::unary_function<typename BF::first_argument_type, typename BF::result_type> {
class Int2DAuxType {
public:
Int2DAuxType(BF const &func, YREG const &yreg, typename BF::result_type const &abserr,
typename BF::result_type const &relerr)
Expand All @@ -653,8 +653,7 @@ class Int2DAuxType : public std::unary_function<typename BF::first_argument_type

// pulled from MoreFunctional.h. Needed in class Int3DAuxtype
template <class TF>
class binder3_1 : public std::binary_function<typename TF::secondof3_argument_type,
typename TF::thirdof3_argument_type, typename TF::result_type> {
class binder3_1 {
public:
binder3_1(const TF &oper, typename TF::firstof3_argument_type val) : _oper(oper), _value(val) {}
typename TF::result_type operator()(typename TF::secondof3_argument_type const &x1,
Expand All @@ -674,8 +673,7 @@ inline binder3_1<TF> bind31(const TF &oper, const Tp &x) {
}

template <class TF, class YREG, class ZREG>
class Int3DAuxType
: public std::unary_function<typename TF::firstof3_argument_type, typename TF::result_type> {
class Int3DAuxType {
public:
Int3DAuxType(const TF &func, const YREG &yreg, const ZREG &zreg, const typename TF::result_type &abserr,
const typename TF::result_type &relerr)
Expand Down
3 changes: 1 addition & 2 deletions src/image/ImagePca.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ namespace {
* The notation is that in chapter 7 of Gyula Szokoly's thesis at JHU
*/
template <typename T>
struct SortEvalueDecreasing
: public std::binary_function<std::pair<T, int> const&, std::pair<T, int> const&, bool> {
struct SortEvalueDecreasing {
bool operator()(std::pair<T, int> const& a, std::pair<T, int> const& b) {
return a.first > b.first; // N.b. sort on greater
}
Expand Down
5 changes: 2 additions & 3 deletions src/math/SpatialCell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ namespace afw {
namespace math {

namespace {
struct CandidatePtrMore : public std::binary_function<std::shared_ptr<SpatialCellCandidate>,
std::shared_ptr<SpatialCellCandidate>, bool> {
struct CandidatePtrMore {
bool operator()(std::shared_ptr<SpatialCellCandidate> a, std::shared_ptr<SpatialCellCandidate> b) {
return a->getCandidateRating() > b->getCandidateRating();
}
Expand Down Expand Up @@ -343,7 +342,7 @@ SpatialCellSet::SpatialCellSet(lsst::geom::Box2I const &region, int xSize, int y
}

namespace {
struct CellContains : public std::unary_function<std::shared_ptr<SpatialCell>, bool> {
struct CellContains {
CellContains(std::shared_ptr<SpatialCellCandidate> candidate) : _candidate(candidate) {}

bool operator()(std::shared_ptr<SpatialCell> cell) {
Expand Down