diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2011-09-21 15:05:45 +0200 |
---|---|---|
committer | Marc Glisse <marc.glisse@inria.fr> | 2011-09-21 15:05:45 +0200 |
commit | a6250b15fb8880ba047624a16693285e5284825a (patch) | |
tree | 3fabc4506522a1cd0c79ebcf5ccbc0b32fcab7e7 /gmpxx.h | |
parent | af14b70ec142e9ce184456a40ee322cc1370c155 (diff) | |
download | gmp-a6250b15fb8880ba047624a16693285e5284825a.tar.gz |
Add swap functions to gmpxx.
Diffstat (limited to 'gmpxx.h')
-rw-r--r-- | gmpxx.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -35,6 +35,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include <iosfwd> #include <cstring> /* for strlen */ +#include <utility> #include <string> #include <stdexcept> #include <cfloat> @@ -1450,6 +1451,8 @@ public: ~__gmp_expr() { mpz_clear(mp); } + void swap(__gmp_expr& z) { std::swap(*mp, *z.mp); } + // assignment operators __gmp_expr & operator=(const __gmp_expr &z) { mpz_set(mp, z.mp); return *this; } @@ -1623,6 +1626,8 @@ public: ~__gmp_expr() { mpq_clear(mp); } + void swap(__gmp_expr& q) { std::swap(*mp, *q.mp); } + // assignment operators __gmp_expr & operator=(const __gmp_expr &q) { mpq_set(mp, q.mp); return *this; } @@ -1828,6 +1833,8 @@ public: ~__gmp_expr() { mpf_clear(mp); } + void swap(__gmp_expr& f) { std::swap(*mp, *f.mp); } + // assignment operators __gmp_expr & operator=(const __gmp_expr &f) { mpf_set(mp, f.mp); return *this; } @@ -2963,6 +2970,9 @@ __GMP_DEFINE_BINARY_FUNCTION(hypot, __gmp_hypot_function) __GMP_DEFINE_UNARY_TYPE_FUNCTION(int, sgn, __gmp_sgn_function) __GMP_DEFINE_BINARY_TYPE_FUNCTION(int, cmp, __gmp_cmp_function) +template <class T> +void swap(__gmp_expr<T, T>& x, __gmp_expr<T, T>& y) { x.swap(y); } + // member operators for mpz_class __GMPZ_DEFINE_COMPOUND_OPERATOR(operator+=, __gmp_binary_plus) |