From d05cc7ccec6ceb8cf3153de04fa789e4d0e5b2f4 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 13 Dec 2001 18:18:52 +0000 Subject: [PATCH] integrating scott snyder's changes [SVN r12042] --- doc/special.html | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/doc/special.html b/doc/special.html index 46ca0791..a72ec671 100644 --- a/doc/special.html +++ b/doc/special.html @@ -287,6 +287,35 @@ bignum_class.def(&rmod, "__rmod__"); found first (be it ``int`` or ``float'') will be used for either of the two types. +

Inplace Operators

+

+ Boost.Python can also be used to expose inplace numeric operations + (i.e., += and so forth). These operators must be wrapped + manually, as described in the previous section. For example, suppose + the class BigNum has an operator+=: + +

+BigNum& operator+= (BigNum const& right);
+
+ + This can be exposed by first writing a wrapper function: + +
+BigNum& iadd (BigNum& self, const BigNum& right)
+{
+  return self += right;
+}
+
+ + and then exposing the wrapper with + +
+bignum_class.def(&iadd, "__iadd__");
+
+ + + +

Coercion