From e888d8aa88198b2a7390fed360ee0adec4fb204a Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 5 Oct 2004 20:40:28 +0000 Subject: [PATCH] Another fix. [SVN r25576] --- doc/v2/operators.html | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/doc/v2/operators.html b/doc/v2/operators.html index aad2e583..6d40beeb 100755 --- a/doc/v2/operators.html +++ b/doc/v2/operators.html @@ -828,19 +828,28 @@ struct number : boost::integer_arithmetic<number> { - number(long x_) : x(x_) {} - operator long() const { return x; } + explicit number(long x_) : x(x_) {} + operator long() const { return x; } - number& operator+=(number const& rhs) - { x += rhs; } - number& operator-=(number const& rhs) - { x -= rhs; } - number& operator*=(number const& rhs) - { x *= rhs; } - number& operator/=(number const& rhs) - { x /= rhs; } - number& operator%=(number const& rhs) - { x %= rhs; } + template <class T> + number& operator+=(T const& rhs) + { x += rhs; return *this; } + + template <class T> + number& operator-=(T const& rhs) + { x -= rhs; return *this; } + + template <class T> + number& operator*=(T const& rhs) + { x *= rhs; return *this; } + + template <class T> + number& operator/=(T const& rhs) + { x /= rhs; return *this; } + + template <class T> + number& operator%=(T const& rhs) + { x %= rhs; return *this; } long x; }; @@ -848,7 +857,7 @@ struct number using namespace boost::python; BOOST_PYTHON_MODULE(demo) { - class_<number>("number") + class_<number>("number", init<long>()) // interoperate with self .def(self += self) .def(self + self)