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-29501: replace unary_function, binary_function, deprecated in C++17 #576

Merged
merged 1 commit into from
Apr 2, 2021
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
8 changes: 4 additions & 4 deletions examples/integrateCartesian.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace math = lsst::afw::math;
* @note We *have* to inherit from unary_function<>
*/
template <typename IntegrandT>
class Parab1D : public std::unary_function<IntegrandT, IntegrandT> {
class Parab1D {
public:
// declare coefficients at instantiation
Parab1D(double const k, double const kx) : _k(k), _kx(kx) {}
Expand All @@ -70,7 +70,7 @@ class Parab1D : public std::unary_function<IntegrandT, IntegrandT> {
* @note we *have* to inherit from binary_function<>
*/
template <typename IntegrandT>
class Parab2D : public std::binary_function<IntegrandT, IntegrandT, IntegrandT> {
class Parab2D {
public:
// declare coefficients at instantiation.
Parab2D(IntegrandT const k, IntegrandT const kx, IntegrandT const ky) : _k(k), _kx(kx), _ky(ky) {}
Expand Down Expand Up @@ -132,7 +132,7 @@ int main() {
double const parab_area_analytic = parab1d.getAnalyticArea(x1, x2);

// now run it on the 1d function (you *need* to wrap the function in ptr_fun())
double const parab_area_integrate_func = math::integrate(std::ptr_fun(parabola), x1, x2);
double const parab_area_integrate_func = math::integrate(parabola, x1, x2);

// output
std::cout << "1D integrate: functor = " << parab_area_integrate
Expand All @@ -149,7 +149,7 @@ int main() {
double const parab_volume_analytic = parab2d.getAnalyticVolume(x1, x2, y1, y2);

// now run it on the 2d function (you *need* to wrap the function in ptr_fun())
double const parab_volume_integrate_func = math::integrate2d(std::ptr_fun(parabola2d), x1, x2, y1, y2);
double const parab_volume_integrate_func = math::integrate2d(parabola2d, x1, x2, y1, y2);

// output
std::cout << "2D integrate: functor = " << parab_volume_integrate
Expand Down
6 changes: 3 additions & 3 deletions examples/integrateExample.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
namespace math = lsst::afw::math;

// A simple Gaussian, parametrized by its center (mu) and size (sigma).
class Gauss : public std::unary_function<double, double> {
class Gauss {
public:
explicit Gauss(double mu, double sig) : _mu(mu), _sig(sig), _sigsq(sig * sig) {}

Expand Down Expand Up @@ -78,7 +78,8 @@ struct Cosmology {
double omM, omV, w, wa;
};

struct W_Integrator : public std::unary_function<double, double> {
class W_Integrator {
public:
W_Integrator(Cosmology const &c) : _c(c) {}
double operator()(double a) const {
// First calculate H^2 according to:
Expand Down Expand Up @@ -140,7 +141,6 @@ int main() {
std::cout << "int(Gauss(0.0, 2.0) , 0..inf) = " << int1d(g02, reg3) << std::endl;

math::IntRegion<double> reg4(0.0, 1.0);
std::cout << "\nint(x*(3*x+y)+y, 0..1, 0..1) = " << int2d(std::ptr_fun(foo), reg4, reg4) << std::endl;

std::cout << "\nIn a universe with:\n\n";
std::cout << "Omega_m = 0.3\n";
Expand Down
4 changes: 2 additions & 2 deletions examples/integratePolar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace math = lsst::afw::math;
* @note that we *have* to inherit from binary_function<>
*/
template <typename IntegrandT>
class Parab2D : public std::binary_function<IntegrandT, IntegrandT, IntegrandT> {
class Parab2D {
public:
// declare coefficients at instantiation.
Parab2D(IntegrandT const k, IntegrandT const kr) : _k(k), _kr(kr) {}
Expand Down Expand Up @@ -96,7 +96,7 @@ int main() {

// now run it on the 2d function (you *need* to wrap the function in ptr_fun())
double const parab_volume_integrate_func =
math::integrate2d(std::ptr_fun(parabola2d), r1, r2, theta1, theta2);
math::integrate2d(parabola2d, r1, r2, theta1, theta2);

// output
std::cout << "2D integrate: functor = " << parab_volume_integrate
Expand Down