Ticket #401: weight-no-copying.patch

File weight-no-copying.patch, 1.8 KB (added by Olly Betts, 15 years ago)

Patch to xapian-core which fixes the copy ctor issues

  • include/xapian/weight.h

     
    7171    /// Don't allow assignment.
    7272    void operator=(const Weight &);
    7373
     74    /// Don't allow copying.
     75    Weight(const Weight &);
     76
    7477    /// A bitmask of the statistics this weighting scheme needs.
    7578    stat_flags stats_needed;
    7679
     
    251254    }
    252255
    253256  protected:
    254     /// Only allow subclasses to copy us.
    255     Weight(const Weight &);
    256 
    257257    /// Default constructor, needed by subclass constructors.
    258258    Weight() : stats_needed() { }
    259259
     
    327327
    328328    Xapian::weight get_sumextra(Xapian::termcount doclen) const;
    329329    Xapian::weight get_maxextra() const;
     330
     331    operator const Xapian::BoolWeight&() const { return *this; }
    330332};
    331333
    332334/// Xapian::Weight subclass implementing the BM25 probabilistic formula.
     
    431433
    432434    Xapian::weight get_sumextra(Xapian::termcount doclen) const;
    433435    Xapian::weight get_maxextra() const;
     436
     437    operator const Xapian::BM25Weight&() const { return *this; }
    434438};
    435439
    436440/** Xapian::Weight subclass implementing the traditional probabilistic formula.
     
    491495
    492496    Xapian::weight get_sumextra(Xapian::termcount doclen) const;
    493497    Xapian::weight get_maxextra() const;
     498
     499    operator const Xapian::TradWeight&() const { return *this; }
    494500};
    495501
    496502}
  • tests/api_db.cc

     
    18981898
    18991899    Xapian::weight get_sumextra(Xapian::termcount) const { return 0; }
    19001900    Xapian::weight get_maxextra() const { return 0; }
     1901
     1902    operator const MyWeight&() const { return *this; }
    19011903};
    19021904
    19031905// tests user weighting scheme.