From: Richard Kreckel Date: Fri, 29 Jan 2016 22:45:21 +0000 (+0100) Subject: [C++17] Remove inheritance from std::binary_function, std::unary_function. X-Git-Tag: release_1-7-0~7^2~14 X-Git-Url: https://ginac.de/ginac.git/static/gitweb.css/ginac.git?a=commitdiff_plain;h=319c9533e12eba2449001c47545e3c3cf48c482f;p=ginac.git [C++17] Remove inheritance from std::binary_function, std::unary_function. This inheritance is unneeded since C++11 and the two classes may be removed in C++-17. --- diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index a8c53797..9af3d527 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -4157,12 +4157,12 @@ provides two functors that can be supplied as proper binary comparison predicates to the STL: @example -class ex_is_less : public std::binary_function @{ +class ex_is_less @{ public: bool operator()(const ex &lh, const ex &rh) const; @}; -class ex_is_equal : public std::binary_function @{ +class ex_is_equal @{ public: bool operator()(const ex &lh, const ex &rh) const; @}; @@ -4190,7 +4190,7 @@ std::sort(v.begin(), v.end(), ex_is_less()); // count the number of expressions equal to '1' unsigned num_ones = std::count_if(v.begin(), v.end(), - std::bind2nd(ex_is_equal(), 1)); + [](const ex& e) @{ return ex_is_equal()(e, 1); @}); @end example The implementation of @code{ex_is_less} uses the member function diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index ab40064f..7ab99281 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -340,7 +340,7 @@ static void base_and_index(const ex & c, ex & b, ex & i) } /** Predicate for finding non-clifford objects. */ -struct is_not_a_clifford : public std::unary_function { +struct is_not_a_clifford { bool operator()(const ex & e) { return !is_a(e); diff --git a/ginac/ex.h b/ginac/ex.h index 21df4305..3b980aab 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -673,19 +673,19 @@ inline bool are_ex_trivially_equal(const ex &e1, const ex &e2) } /* Function objects for STL sort() etc. */ -struct ex_is_less : public std::binary_function { +struct ex_is_less { bool operator() (const ex &lh, const ex &rh) const { return lh.compare(rh) < 0; } }; -struct ex_is_equal : public std::binary_function { +struct ex_is_equal { bool operator() (const ex &lh, const ex &rh) const { return lh.is_equal(rh); } }; -struct op0_is_equal : public std::binary_function { +struct op0_is_equal { bool operator() (const ex &lh, const ex &rh) const { return lh.op(0).is_equal(rh.op(0)); } }; -struct ex_swap : public std::binary_function { +struct ex_swap { void operator() (ex &lh, ex &rh) const { lh.swap(rh); } }; diff --git a/ginac/expair.h b/ginac/expair.h index b37fb165..443f20a9 100644 --- a/ginac/expair.h +++ b/ginac/expair.h @@ -92,7 +92,7 @@ public: }; /** Function object for insertion into third argument of STL's sort() etc. */ -struct expair_is_less : public std::binary_function { +struct expair_is_less { bool operator()(const expair &lh, const expair &rh) const { return lh.is_less(rh); } }; @@ -100,11 +100,11 @@ struct expair_is_less : public std::binary_function { * into third argument of STL's sort(). Note that this does not define a * strict weak ordering since for any symbol x we have neither 3*x<2*x or * 2*x<3*x. Handle with care! */ -struct expair_rest_is_less : public std::binary_function { +struct expair_rest_is_less { bool operator()(const expair &lh, const expair &rh) const { return (lh.rest.compare(rh.rest)<0); } }; -struct expair_swap : public std::binary_function { +struct expair_swap { void operator()(expair &lh, expair &rh) const { lh.swap(rh); } }; diff --git a/ginac/hash_map.h b/ginac/hash_map.h index 2616a284..6d334d7d 100644 --- a/ginac/hash_map.h +++ b/ginac/hash_map.h @@ -192,7 +192,7 @@ public: typedef typename Table::size_type size_type; typedef typename Table::difference_type difference_type; - class value_compare : public std::binary_function, private key_compare { + class value_compare : private key_compare { friend class exhashmap; public: bool operator()(const value_type &lhs, const value_type &rhs) const diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp index 86af6811..77c8eb5c 100644 --- a/ginac/indexed.cpp +++ b/ginac/indexed.cpp @@ -394,7 +394,7 @@ ex indexed::derivative(const symbol & s) const // global functions ////////// -struct idx_is_equal_ignore_dim : public std::binary_function { +struct idx_is_equal_ignore_dim { bool operator() (const ex &lh, const ex &rh) const { if (lh.is_equal(rh)) @@ -506,7 +506,7 @@ exvector ncmul::get_free_indices() const return free_indices; } -struct is_summation_idx : public std::unary_function { +struct is_summation_idx { bool operator()(const ex & e) { return is_dummy_pair(e, e); @@ -719,7 +719,7 @@ next_index: ; } /* Ordering that only compares the base expressions of indexed objects. */ -struct ex_base_is_less : public std::binary_function { +struct ex_base_is_less { bool operator() (const ex &lh, const ex &rh) const { return (is_a(lh) ? lh.op(0) : lh).compare(is_a(rh) ? rh.op(0) : rh) < 0; diff --git a/ginac/ptr.h b/ginac/ptr.h index 29db2350..b7736c7c 100644 --- a/ginac/ptr.h +++ b/ginac/ptr.h @@ -155,8 +155,7 @@ namespace std { /** Specialization of std::less for ptr to enable ordering of ptr * objects (e.g. for the use as std::map keys). */ -template struct less> - : public binary_function, GiNaC::ptr, bool> { +template struct less> { bool operator()(const GiNaC::ptr &lhs, const GiNaC::ptr &rhs) const { return less()(lhs.p, rhs.p); diff --git a/ginac/symmetry.cpp b/ginac/symmetry.cpp index c8c27a03..614b1173 100644 --- a/ginac/symmetry.cpp +++ b/ginac/symmetry.cpp @@ -389,7 +389,7 @@ const symmetry & antisymmetric4() return ex_to(s); } -class sy_is_less : public std::binary_function { +class sy_is_less { exvector::iterator v; public: @@ -413,7 +413,7 @@ public: } }; -class sy_swap : public std::binary_function { +class sy_swap { exvector::iterator v; public: