From f3357f1f5709f6008418f839cca336250c807841 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Jun 2019 19:05:46 +0100 Subject: [PATCH] Remove use of std::bind2nd which is removed in C++17 --- Doc/Manual/Library.html | 4 ++-- Examples/guile/std_vector/example.h | 5 ++--- Examples/mzscheme/std_vector/example.h | 5 ++--- Examples/ocaml/std_vector/example.h | 5 ++--- Examples/python/std_vector/example.h | 5 ++--- Examples/ruby/std_vector/example.h | 5 ++--- Examples/scilab/std_vector/example.h | 5 ++--- Examples/tcl/std_vector/example.h | 5 ++--- Examples/test-suite/li_std_deque.i | 4 ++-- Examples/test-suite/li_std_list.i | 4 ++-- Examples/test-suite/li_std_vector.i | 4 ++-- Examples/test-suite/li_std_vector_extra.i | 4 ++-- 12 files changed, 24 insertions(+), 31 deletions(-) diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index eeb2e5a57..560859234 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -1581,8 +1581,8 @@ std::vector<double> half(const std::vector<double>& v) { } void halve_in_place(std::vector<double>& v) { - std::transform(v.begin(), v.end(), v.begin(), - std::bind2nd(std::divides<double>(), 2.0)); + for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/guile/std_vector/example.h b/Examples/guile/std_vector/example.h index 4f0dac70d..52e260d6d 100644 --- a/Examples/guile/std_vector/example.h +++ b/Examples/guile/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/mzscheme/std_vector/example.h b/Examples/mzscheme/std_vector/example.h index 4f0dac70d..52e260d6d 100644 --- a/Examples/mzscheme/std_vector/example.h +++ b/Examples/mzscheme/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/ocaml/std_vector/example.h b/Examples/ocaml/std_vector/example.h index b75359243..d968f6953 100644 --- a/Examples/ocaml/std_vector/example.h +++ b/Examples/ocaml/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/python/std_vector/example.h b/Examples/python/std_vector/example.h index 4f0dac70d..52e260d6d 100644 --- a/Examples/python/std_vector/example.h +++ b/Examples/python/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/ruby/std_vector/example.h b/Examples/ruby/std_vector/example.h index 4f0dac70d..52e260d6d 100644 --- a/Examples/ruby/std_vector/example.h +++ b/Examples/ruby/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/scilab/std_vector/example.h b/Examples/scilab/std_vector/example.h index 4f0dac70d..52e260d6d 100644 --- a/Examples/scilab/std_vector/example.h +++ b/Examples/scilab/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/tcl/std_vector/example.h b/Examples/tcl/std_vector/example.h index 4f0dac70d..52e260d6d 100644 --- a/Examples/tcl/std_vector/example.h +++ b/Examples/tcl/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/test-suite/li_std_deque.i b/Examples/test-suite/li_std_deque.i index 152bc86c1..c2f4a7f45 100644 --- a/Examples/test-suite/li_std_deque.i +++ b/Examples/test-suite/li_std_deque.i @@ -36,8 +36,8 @@ std::deque half(const std::deque& v) { } void halve_in_place(std::deque& v) { - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::deque::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } %} diff --git a/Examples/test-suite/li_std_list.i b/Examples/test-suite/li_std_list.i index 9cc6220d2..2ed5b9ad7 100644 --- a/Examples/test-suite/li_std_list.i +++ b/Examples/test-suite/li_std_list.i @@ -30,8 +30,8 @@ double average(std::list v) { void halve_in_place(std::list& v) { - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::list::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } struct Struct { diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i index ada146cc4..33fb79720 100644 --- a/Examples/test-suite/li_std_vector.i +++ b/Examples/test-suite/li_std_vector.i @@ -48,8 +48,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } struct Struct { diff --git a/Examples/test-suite/li_std_vector_extra.i b/Examples/test-suite/li_std_vector_extra.i index 103242b24..70b776b37 100644 --- a/Examples/test-suite/li_std_vector_extra.i +++ b/Examples/test-suite/li_std_vector_extra.i @@ -62,8 +62,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } %}