1From f1c5309d5b815acc2616cd9fbb5182b1e64d225f Mon Sep 17 00:00:00 2001
2From: George Huebner <george@feyor.sh>
3Date: Wed, 17 Jul 2024 18:12:36 -0500
4Subject: [PATCH 1/4] remove old <functional> patterns
5
6pointer_to_binary_function and ptr_fun are holdovers from pre c++11,
7and can be replaced or entirely removed. This allows Giac to compile
8with Clang 16>=.
9---
10 src/all_global_var | 2 +-
11 src/gausspol.cc | 2 +-
12 src/gausspol.h | 2 +-
13 src/gen.cc | 2 +-
14 src/gen.h | 4 ++--
15 src/maple.cc | 2 +-
16 src/monomial.h | 16 ++++++++--------
17 src/plot.cc | 2 +-
18 src/poly.h | 17 +++++++++--------
19 src/solve.cc | 18 +++++++++---------
20 src/usual.cc | 2 +-
21 11 files changed, 35 insertions(+), 34 deletions(-)
22
23diff --git a/src/all_global_var b/src/all_global_var
24index 7d75d73..55f4782 100644
25--- a/src/all_global_var
26+++ b/src/all_global_var
27@@ -16,7 +16,7 @@ Relatif a l'evaluation du tableur
28 // File Eqw.cc
29 vector<string> completion_tab;
30 // File alg_ext.cc
31- rootmap symbolic_rootof_list(ptr_fun(islesscomplex));
32+ rootmap symbolic_rootof_list(islesscomplex);
33 // File derive.cc
34 // File desolve.cc
35 identificateur laplace_var(" s");
36diff --git a/src/gausspol.cc b/src/gausspol.cc
37index 8fbd581..2f2121f 100644
38--- a/src/gausspol.cc
39+++ b/src/gausspol.cc
40@@ -855,7 +855,7 @@ namespace giac {
41 std::vector< monomial<gen> >::const_iterator & itb_end,
42 std::vector< monomial<gen> > & new_coord,
43 bool (* is_strictly_greater)( const index_m &, const index_m &),
44- const std::pointer_to_binary_function < const monomial<gen> &, const monomial<gen> &, bool> m_is_strictly_greater
45+ const std::function<bool(const monomial<gen> &, const monomial<gen> &)> m_is_strictly_greater
46 ) {
47 if (ita==ita_end || itb==itb_end){
48 new_coord.clear();
49diff --git a/src/gausspol.h b/src/gausspol.h
50index b5d214b..e6c7e0c 100644
51--- a/src/gausspol.h
52+++ b/src/gausspol.h
53@@ -93,7 +93,7 @@ namespace giac {
54 std::vector< monomial<gen> >::const_iterator & itb_end,
55 std::vector< monomial<gen> > & new_coord,
56 bool (* is_strictly_greater)( const index_t &, const index_t &),
57- const std::pointer_to_binary_function < const monomial<gen> &, const monomial<gen> &, bool> m_is_greater
58+ const std::function<bool(const monomial<gen> &, const monomial<gen> &)> m_is_greater
59 ) ;
60 void mulpoly(const polynome & th,const gen & fact,polynome & res);
61 polynome operator * (const polynome & th, const gen & fact) ;
62diff --git a/src/gen.cc b/src/gen.cc
63index 7d4874c..0b64afe 100644
64--- a/src/gen.cc
65+++ b/src/gen.cc
66@@ -1126,7 +1126,7 @@ namespace giac {
67 #if 1 // def NSPIRE
68 g.__MAPptr = new ref_gen_map;
69 #else
70- g.__MAPptr = new ref_gen_map(ptr_fun(islesscomplexthanf));
71+ g.__MAPptr = new ref_gen_map(islesscomplexthanf);
72 #endif
73 #endif
74 g.type=_MAP;
75diff --git a/src/gen.h b/src/gen.h
76index 04d70af..496b25d 100644
77--- a/src/gen.h
78+++ b/src/gen.h
79@@ -443,7 +443,7 @@ namespace giac {
80 };
81 typedef std::map<gen,gen,comparegen> gen_map;
82 #else
83- typedef std::map<gen,gen,const std::pointer_to_binary_function < const gen &, const gen &, bool> > gen_map;
84+ typedef std::map<gen,gen,const std::function<bool(const gen &, const gen &)> > gen_map;
85 #endif
86 struct ref_gen_map;
87
88@@ -902,7 +902,7 @@ namespace giac {
89 #if 1 // def NSPIRE
90 ref_gen_map(): ref_count(1),m() {}
91 #else
92- ref_gen_map(const std::pointer_to_binary_function < const gen &, const gen &, bool> & p): ref_count(1),m(p) {}
93+ ref_gen_map(const std::function<bool(const gen &, const gen &)> & p): ref_count(1),m(p) {}
94 #endif
95 ref_gen_map(const gen_map & M):ref_count(1),m(M) {}
96 };
97diff --git a/src/maple.cc b/src/maple.cc
98index 3b33da8..d57a170 100644
99--- a/src/maple.cc
100+++ b/src/maple.cc
101@@ -3626,7 +3626,7 @@ namespace giac {
102 #if 1 // def NSPIRE
103 gen_map m;
104 #else
105- gen_map m(ptr_fun(islessthanf));
106+ gen_map m(islessthanf);
107 #endif
108 int s=int(args.size());
109 vector<int> indexbegin,indexsize;
110diff --git a/src/monomial.h b/src/monomial.h
111index 6e606d0..637a76c 100644
112--- a/src/monomial.h
113+++ b/src/monomial.h
114@@ -338,9 +338,9 @@ namespace giac {
115
116 template<class T> class sort_helper {
117 public:
118- std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> strictly_greater ;
119- sort_helper(const std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> is_strictly_greater):strictly_greater(is_strictly_greater) {};
120- sort_helper():strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) {};
121+ std::function<bool(const monomial<T> &, const monomial<T> &)> strictly_greater ;
122+ sort_helper(const std::function<bool(const monomial<T> &, const monomial<T> &)> is_strictly_greater):strictly_greater(is_strictly_greater) {};
123+ sort_helper():strictly_greater(m_lex_is_strictly_greater<T>) {};
124 bool operator () (const monomial<T> & a, const monomial<T> & b){ return strictly_greater(a,b);}
125 };
126
127@@ -677,7 +677,7 @@ namespace giac {
128 typename std::vector< monomial<T> >::const_iterator & itb_end,
129 std::vector< monomial<T> > & new_coord,
130 bool (* is_strictly_greater)( const index_m &, const index_m &),
131- const std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> m_is_strictly_greater
132+ const std::function<bool(const monomial<T> &, const monomial<T> &)> m_is_strictly_greater
133 ) {
134 if (ita==ita_end || itb==itb_end){
135 new_coord.clear();
136@@ -726,8 +726,8 @@ namespace giac {
137 #endif
138 #ifndef NSPIRE
139 /* other algorithm using a map to avoid reserving too much space */
140- typedef std::map< index_t,T,const std::pointer_to_binary_function < const index_m &, const index_m &, bool> > application;
141- application produit(std::ptr_fun(is_strictly_greater));
142+ typedef std::map< index_t,T,const std::function<bool(const index_m &, const index_m &)> > application;
143+ application produit(is_strictly_greater);
144 // typedef std::map<index_t,T> application;
145 // application produit;
146 index_t somme(ita->index.size());
147@@ -848,7 +848,7 @@ namespace giac {
148 typename std::vector< monomial<T> >::const_iterator a=v.begin(), a_end=v.end();
149 typename std::vector< monomial<T> >::const_iterator b=w.begin(), b_end=w.end();
150 std::vector< monomial<T> > res;
151- Mul(a,a_end,b,b_end,res,i_lex_is_strictly_greater,std::ptr_fun< const monomial<T> &, const monomial<T> &, bool >((m_lex_is_strictly_greater<T>)));
152+ Mul(a,a_end,b,b_end,res,i_lex_is_strictly_greater,m_lex_is_strictly_greater<T>);
153 return res ;
154 }
155
156@@ -856,7 +856,7 @@ namespace giac {
157 std::vector< monomial<T> > & operator *= (std::vector< monomial<T> > & v,const std::vector< monomial<T> > & w){
158 typename std::vector< monomial<T> >::const_iterator a=v.begin(), a_end=v.end();
159 typename std::vector< monomial<T> >::const_iterator b=w.begin(), b_end=w.end();
160- Mul(a,a_end,b,b_end,v,i_lex_is_strictly_greater,std::ptr_fun< const monomial<T> &, const monomial<T> &, bool >((m_lex_is_strictly_greater<T>)));
161+ Mul(a,a_end,b,b_end,v,i_lex_is_strictly_greater,m_lex_is_strictly_greater<T>);
162 return v;
163 }
164
165diff --git a/src/plot.cc b/src/plot.cc
166index 288a1b5..ac85c9a 100755
167--- a/src/plot.cc
168+++ b/src/plot.cc
169@@ -11886,7 +11886,7 @@ static vecteur densityscale(double xmin,double xmax,double ymin,double ymax,doub
170 #if 1 // def NSPIRE
171 gen_map m;
172 #else
173- gen_map m(ptr_fun(islesscomplexthanf));
174+ gen_map m(islesscomplexthanf);
175 #endif
176 int taille;
177 is >> taille;
178diff --git a/src/poly.h b/src/poly.h
179index 7d64e2c..d9ff991 100644
180--- a/src/poly.h
181+++ b/src/poly.h
182@@ -40,23 +40,24 @@ namespace giac {
183 // T zero;
184 // functional object sorting function for monomial ordering
185 bool (* is_strictly_greater)( const index_m &, const index_m &);
186- std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> m_is_strictly_greater ;
187+ std::function<bool(const monomial<T> &, const monomial<T> &)> m_is_strictly_greater ;
188 // constructors
189 tensor(const tensor<T> & t) : dim(t.dim), coord(t.coord), is_strictly_greater(t.is_strictly_greater), m_is_strictly_greater(t.m_is_strictly_greater) { }
190 tensor(const tensor<T> & t, const std::vector< monomial<T> > & v) : dim(t.dim), coord(v), is_strictly_greater(t.is_strictly_greater), m_is_strictly_greater(t.m_is_strictly_greater) { }
191 // warning: this constructor prohibits construction of tensor from a value
192 // of type T if this value is an int, except by using tensor<T>(T(int))
193- tensor() : dim(0), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) { }
194- explicit tensor(int d) : dim(d), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) { }
195+ // DANGER
196+ tensor() : dim(0), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(m_lex_is_strictly_greater<T>) { }
197+ explicit tensor(int d) : dim(d), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(m_lex_is_strictly_greater<T>) { }
198 explicit tensor(int d,const tensor<T> & t) : dim(d),is_strictly_greater(t.is_strictly_greater), m_is_strictly_greater(t.m_is_strictly_greater) { }
199- tensor(const monomial<T> & v) : dim(int(v.index.size())), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) {
200+ tensor(const monomial<T> & v) : dim(int(v.index.size())), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(m_lex_is_strictly_greater<T>) {
201 coord.push_back(v);
202 }
203- tensor(const T & v, int d) : dim(d), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) {
204+ tensor(const T & v, int d) : dim(d), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(m_lex_is_strictly_greater<T>) {
205 if (!is_zero(v))
206 coord.push_back(monomial<T>(v,0,d));
207 }
208- tensor(int d,const std::vector< monomial<T> > & c) : dim(d), coord(c), is_strictly_greater(i_lex_is_strictly_greater),m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) { }
209+ tensor(int d,const std::vector< monomial<T> > & c) : dim(d), coord(c), is_strictly_greater(i_lex_is_strictly_greater),m_is_strictly_greater(m_lex_is_strictly_greater<T>) { }
210 ~tensor() { coord.clear(); }
211 // member functions
212 // ordering monomials in the tensor
213@@ -519,10 +520,10 @@ namespace giac {
214 template <class T>
215 void lexsort(std::vector < monomial<T> > & v){
216 #if 1 // def NSPIRE
217- sort_helper<T> M(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>));
218+ sort_helper<T> M(m_lex_is_strictly_greater<T>);
219 sort(v.begin(),v.end(),M);
220 #else
221- sort(v.begin(),v.end(),std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>));
222+ sort(v.begin(),v.end(),m_lex_is_strictly_greater<T>);
223 #endif
224 }
225
226diff --git a/src/solve.cc b/src/solve.cc
227index 889f824..2a51ab8 100755
228--- a/src/solve.cc
229+++ b/src/solve.cc
230@@ -8684,39 +8684,39 @@ namespace giac {
231 switch (order.val){
232 case _PLEX_ORDER:
233 p.is_strictly_greater=i_lex_is_strictly_greater;
234- p.m_is_strictly_greater=std::ptr_fun(m_lex_is_strictly_greater<gen>);
235+ p.m_is_strictly_greater=m_lex_is_strictly_greater<gen>;
236 break;
237 case _REVLEX_ORDER:
238 p.is_strictly_greater=i_total_revlex_is_strictly_greater;
239- p.m_is_strictly_greater=std::ptr_fun(m_total_revlex_is_strictly_greater<gen>);
240+ p.m_is_strictly_greater=m_total_revlex_is_strictly_greater<gen>;
241 break;
242 case _TDEG_ORDER:
243 p.is_strictly_greater=i_total_lex_is_strictly_greater;
244- p.m_is_strictly_greater=std::ptr_fun(m_total_lex_is_strictly_greater<gen>);
245+ p.m_is_strictly_greater=m_total_lex_is_strictly_greater<gen>;
246 break;
247 case _3VAR_ORDER:
248 p.is_strictly_greater=i_3var_is_strictly_greater;
249- p.m_is_strictly_greater=std::ptr_fun(m_3var_is_strictly_greater<gen>);
250+ p.m_is_strictly_greater=m_3var_is_strictly_greater<gen>;
251 break;
252 case _7VAR_ORDER:
253 p.is_strictly_greater=i_7var_is_strictly_greater;
254- p.m_is_strictly_greater=std::ptr_fun(m_7var_is_strictly_greater<gen>);
255+ p.m_is_strictly_greater=m_7var_is_strictly_greater<gen>;
256 break;
257 case _11VAR_ORDER:
258 p.is_strictly_greater=i_11var_is_strictly_greater;
259- p.m_is_strictly_greater=std::ptr_fun(m_11var_is_strictly_greater<gen>);
260+ p.m_is_strictly_greater=m_11var_is_strictly_greater<gen>;
261 break;
262 case _16VAR_ORDER:
263 p.is_strictly_greater=i_16var_is_strictly_greater;
264- p.m_is_strictly_greater=std::ptr_fun(m_16var_is_strictly_greater<gen>);
265+ p.m_is_strictly_greater=m_16var_is_strictly_greater<gen>;
266 break;
267 case _32VAR_ORDER:
268 p.is_strictly_greater=i_32var_is_strictly_greater;
269- p.m_is_strictly_greater=std::ptr_fun(m_32var_is_strictly_greater<gen>);
270+ p.m_is_strictly_greater=m_32var_is_strictly_greater<gen>;
271 break;
272 case _64VAR_ORDER:
273 p.is_strictly_greater=i_64var_is_strictly_greater;
274- p.m_is_strictly_greater=std::ptr_fun(m_64var_is_strictly_greater<gen>);
275+ p.m_is_strictly_greater=m_64var_is_strictly_greater<gen>;
276 break;
277 }
278 p.tsort();
279diff --git a/src/usual.cc b/src/usual.cc
280index fddede6..eb7ae5e 100755
281--- a/src/usual.cc
282+++ b/src/usual.cc
283@@ -5950,7 +5950,7 @@ namespace giac {
284 #if 1 // def NSPIRE
285 gen_map m;
286 #else
287- gen_map m(ptr_fun(islesscomplexthanf));
288+ gen_map m(islesscomplexthanf);
289 #endif
290 for (;it!=itend;++it){
291 if (is_equal(*it) || it->is_symb_of_sommet(at_deuxpoints)){
292--
2932.44.1
294