[Xapian-tickets] [Xapian] #401: Weight cannot be subclassed in bindings

Xapian nobody at xapian.org
Fri Sep 18 07:06:58 BST 2009


#401: Weight cannot be subclassed in bindings
-----------------------------+----------------------------------------------
 Reporter:  james            |       Owner:  olly    
     Type:  enhancement      |      Status:  assigned
 Priority:  normal           |   Milestone:  1.1.7   
Component:  Xapian-bindings  |     Version:          
 Severity:  normal           |    Keywords:          
Blockedby:                   |    Platform:  All     
 Blocking:                   |  
-----------------------------+----------------------------------------------
Changes (by olly):

  * milestone:  1.2.0 => 1.1.7


Comment:

 attachment:weight-no-copying.patch fixes this, but the downside is that
 any user subclass of Xapian::Weight needs to have:

 {{{
 #!cpp
     operator const MyWeight&() const { return *this; }
 }}}

 Or else you can't use it like so:

 {{{
 #!cpp
     enquire.set_weighting_scheme(MyWeight());
 }}}

 And would have to instead write:

 {{{
 #!cpp
     {
         MyWeight temp;
         enquire.set_weighting_scheme(temp);
     }
 }}}

 I don't know why the compiler wants to copy a temporary object to pass it
 by const reference - that seems kind of dumb to me, but perhaps it is a
 requirement of C++ which GCC (4.1.2) is checking, and the copy actually
 gets optimised away.

 Marking for 1.1.7 for now, since if we decide the above approach is OK, we
 should do it before 1.2.0 (and we do have a patch for it already, so it's
 not going to cause much delay).

-- 
Ticket URL: <http://trac.xapian.org/ticket/401#comment:4>
Xapian <http://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list