diff options
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) |