X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fex.h;h=1f4ead98ddf358ab1d3012bb960150e0b0722ce1;hp=30a009eb80dde265b52a66017f65f31a09a8dc03;hb=c94cbc55628a5ccf536dfc63c5512d626ae647b6;hpb=724a356fc958e5e54a584dcac0812aa65a149f65;ds=sidebyside diff --git a/ginac/ex.h b/ginac/ex.h index 30a009eb..1f4ead98 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -604,12 +604,6 @@ inline bool is_zero(const ex & thisex) inline void swap(ex & e1, ex & e2) { e1.swap(e2); } - -// This makes STL algorithms use the more efficient swap operation for ex objects -inline void iter_swap(std::vector::iterator i1, std::vector::iterator i2) -{ i1->swap(*i2); } - - /* Function objects for STL sort() etc. */ struct ex_is_less : public std::binary_function { bool operator() (const ex &lh, const ex &rh) const { return lh.compare(rh) < 0; } @@ -723,4 +717,31 @@ inline const T &ex_to(const ex &e) } // namespace GiNaC + +// Specializations of Standard Library algorithms +namespace std { + +/** Specialization of std::swap() for ex objects. */ +template <> +inline void swap(GiNaC::ex &a, GiNaC::ex &b) +{ + a.swap(b); +} + +/** Specialization of std::iter_swap() for vector iterators. */ +template <> +inline void iter_swap(vector::iterator i1, vector::iterator i2) +{ + i1->swap(*i2); +} + +/** Specialization of std::iter_swap() for list iterators. */ +template <> +inline void iter_swap(list::iterator i1, list::iterator i2) +{ + i1->swap(*i2); +} + +} // namespace std + #endif // ndef __GINAC_EX_H__