[C++-sig] Just about to release

David Abrahams dave at boost-consulting.com
Wed Oct 9 21:42:39 CEST 2002


Stefan Seefeld <seefeld at sympatico.ca> writes:

> the file class_operators_special_functions.html
> contains special method definitions for Rational:
> 
> 
>   class Rational
>      { operator double() const; };
> 
>      Rational pow(Rational, Rational);
>      Rational abs(Rational);
>      ostream& operator<<(ostream&,Rational);
> 
>      class_<Rational>()
>          .def(float_(self))  // __float__
>          .def(pow(self))     // __pow__
>          .def(abs(self))     // __abs__
>          .def(str(self))     // __str__
>          ;
> 
> shouldn't that read 'pow(self, other<Rational>)' ?

Yep, that's right.

> And what about 'str' ? 

str is fine.

> How is the link to 'operator <<' established ?

In the same way that "self + self" establishes a link to
operator+(Rational,Rational) (or whatever the signature ends up
being).

> Something is missing here...

What is it?

-- 
           David Abrahams * Boost Consulting
dave at boost-consulting.com * http://www.boost-consulting.com





More information about the Cplusplus-sig mailing list