[C++-sig] Re: custom less than operator? to_python_converter for multiple destination types?
Gavin Doughtie
gdoughtie at anim.dreamworks.com
Fri May 30 22:38:11 CEST 2003
OK, that's exactly what I ended up doing. Just thinking there might be
something niftier.
Gavin
David Abrahams wrote:
> Gavin Doughtie <gdoughtie at anim.dreamworks.com> writes:
>
>
>>So, I'm wrapping a class that defines "<" as an internal class with a
>>bool operator() like so:
>>
>>struct Baz
>>{
>> struct Less
>> {
>> bool operator() (const Baz& a, const Baz& b) const;
>> }
>>};
>>
>>Inconveniently, it also does NOT define operator < in Baz. How would I
>>wrap this to make Baz objects in Python use Baz::Less::operator() as
>>the < operator?
>
>
>
>
> bool BazLess(Baz const& a, Baz const& b) { return Baz::Less()(a,b); }
>
> class <Baz>("Baz")
> .def("__lt__", BazLess)
> ...
>
>
>
> HTH,
--
Gavin Doughtie
DreamWorks SKG
(818) 695-3821
More information about the Cplusplus-sig
mailing list