This file is indexed.

/usr/include/Rivet/Cmp.hh is in librivet-dev 1.8.3-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
// -*- C++ -*-
#ifndef RIVET_Cmp_HH
#define RIVET_Cmp_HH

#include "Rivet/Rivet.hh"
#include "Rivet/Projection.hh"
#include "Cmp.fhh"
#include <typeinfo>


namespace Rivet {


  /// Helper class when checking the ordering of two objects.
  ///
  /// Cmp is a helper class to be used when checking the ordering of two
  /// objects. When implicitly converted to an integer the value will be
  /// negative if the two objects used in the constructor are ordered and
  /// positive if they are not. Zero will be returned if they are equal.
  ///
  /// The main usage of the Cmp class is if several variables should be
  /// checked for ordering in which case several Cmp objects can be
  /// combined as follows: <code>cmp(a1, a2) || cmp(b1, b2) || cmp(c1,
  /// c2)</code> where cmp is a global function for easy creation of Cmp
  /// objects.
  template <typename T>
  class Cmp {
  public:

    /// @name Standard constructors etc.
    //@{

    /// The default constructor.
    Cmp(const T& t1, const T& t2)
      : _value(UNDEFINED), _objects(&t1, &t2) { }

    /// The copy constructor.
    template <typename U>
    Cmp(const Cmp<U>& x)
      : _value(x), _objects(0, 0) { }

    /// The destructor is not virtual since this is not intended to be a base class.
    ~Cmp() { };

    /// The assignment operator.
    template <typename U>
    const Cmp<T>& operator=(const Cmp<U>& x) {
      _value = x;
      return *this;
    }

    //@}

  public:

    /// Automatically convert to an enum.
    operator CmpState() const {
      _compare();
      return _value;
    }

    /// Automatically convert to an integer.
    operator int() const {
      _compare();
      return _value;
    }

    /// If this state is equivalent, set this state to the state of \a c.
    template <typename U>
    const Cmp<T>& operator||(const Cmp<U>& c) const {
      _compare();
      if (_value == EQUIVALENT) _value = c;
      return *this;
    }

  private:

    /// Perform the actual comparison if necessary.
    void _compare() const {
      if (_value == UNDEFINED) {
        less<T> l;
        if ( l(*_objects.first, *_objects.second) ) _value = ORDERED;
        else if ( l(*_objects.second, *_objects.first) ) _value = UNORDERED;
        else _value = EQUIVALENT;
      }
    }

    /// The state of this object.
    mutable CmpState _value;

    /// The objects to be compared.
    pair<const T*, const T*> _objects;

  };


  /// @brief Specialization of Cmp for checking the ordering of two @a {Projection}s.
  ///
  /// Specialization of the Cmp helper class to be used when checking the
  /// ordering of two Projection objects. When implicitly converted to an
  /// integer the value will be negative if the two objects used in the
  /// constructor are ordered and positive if they are not. Zero will be
  /// returned if they are equal. This specialization uses directly the
  /// virtual compare() function in the Projection class.
  ///
  /// The main usage of the Cmp class is if several variables should be
  /// checked for ordering in which case several Cmp objects can be
  /// combined as follows: <code>cmp(a1, a2) || cmp(b1, b2) || cmp(c1,
  /// c2)</code> where cmp is a global function for easy creation of Cmp
  /// objects.
  template <>
  class Cmp<Projection> {
  public:

    /// @name Standard constructors and destructors.
    //@{
    /// The default constructor.
    Cmp(const Projection& p1, const Projection& p2)
      : _value(UNDEFINED), _objects(&p1, &p2)
    { }

    /// The copy constructor.
    template <typename U>
    Cmp(const Cmp<U>& x)
      : _value(x), _objects(0, 0)
    { }

    /// The destructor is not virtual since this is not intended to be a base class.
    ~Cmp() { };

    /// The assignment operator.
    template <typename U>
    const Cmp<Projection>& operator=(const Cmp<U>& x) {
      _value = x;
      return *this;
    }
    //@}

  public:

    /// Automatically convert to an enum.
    operator CmpState() const {
      _compare();
      return _value;
    }


    /// Automatically convert to an integer.
    operator int() const {
      _compare();
      return _value;
    }

    /// If this state is equivalent, set this state to the state of \a c.
    template <typename U>
    const Cmp<Projection>& operator||(const Cmp<U>& c) const {
      _compare();
      if (_value == EQUIVALENT) _value = c;
      return *this;
    }

  private:

    /// Perform the actual comparison if necessary.
    void _compare() const {
      if (_value == UNDEFINED) {
        const std::type_info& id1 = typeid(*_objects.first);
        const std::type_info& id2 = typeid(*_objects.second);
        if (id1.before(id2)) _value = ORDERED;
        else if (id2.before(id1)) _value = UNORDERED;
        else {
          int c = _objects.first->compare(*_objects.second);
          if (c < 0) _value = ORDERED;
          else if (c > 0) _value = UNORDERED;
          else _value = EQUIVALENT;
        }
      }
    }

  private:

    /// The state of this object.
    mutable CmpState _value;

    /// The objects to be compared.
    pair<const Projection*, const Projection*> _objects;

  };




  /// @brief Specialization of Cmp for checking the ordering of two floating point numbers.
  ///
  /// When implicitly converted to an integer the value will be negative if the
  /// two objects used in the constructor are ordered and positive if they are
  /// not. Zero will be returned if they are equal. This specialization uses the
  /// Rivet fuzzyEquals function to indicate equivalence protected from
  /// numerical precision effects.
  ///
  /// The main usage of the Cmp class is if several variables should be
  /// checked for ordering in which case several Cmp objects can be
  /// combined as follows: <code>cmp(a1, a2) || cmp(b1, b2) || cmp(c1,
  /// c2)</code> where cmp is a global function for easy creation of Cmp
  /// objects.
  template <>
  class Cmp<double> {
  public:

    /// @name Standard constructors and destructors.
    //@{
    /// The default constructor.
    Cmp(const double p1, const double p2)
      : _value(UNDEFINED), _numA(p1), _numB(p2)
    { }

    /// The copy constructor.
    template <typename U>
    Cmp(const Cmp<U>& x)
      : _value(x), _numA(0.0), _numB(0.0)
    { }

    /// The destructor is not virtual since this is not intended to be a base class.
    ~Cmp() { }

    /// The assignment operator.
    template <typename U>
    const Cmp<double>& operator=(const Cmp<U>& x) {
      _value = x;
      return *this;
    }
    //@}

  public:

    /// Automatically convert to an enum.
    operator CmpState() const {
      _compare();
      return _value;
    }

    /// Automatically convert to an integer.
    operator int() const {
      _compare();
      return _value;
    }

    /// If this state is equivalent, set this state to the state of \a c.
    template <typename U>
    const Cmp<double>& operator||(const Cmp<U>& c) const {
      _compare();
      if (_value == EQUIVALENT) _value = c;
      return *this;
    }

  private:

    /// Perform the actual comparison if necessary.
    void _compare() const {
      if (_value == UNDEFINED) {
        if (fuzzyEquals(_numA,_numB)) _value = EQUIVALENT;
        else if (_numA < _numB) _value = ORDERED;
        else _value = UNORDERED;
      }
    }

  private:

    /// The state of this object.
    mutable CmpState _value;

    /// The objects to be compared.
    double _numA, _numB;

  };



  ///////////////////////////////////////////////////////////////////



  /// Global helper function for easy creation of Cmp objects.
  template <typename T>
  inline Cmp<T> cmp(const T& t1, const T& t2) {
    return Cmp<T>(t1, t2);
  }


  /// Typedef for Cmp<Projection>
  typedef Cmp<Projection> PCmp;


  /// Global helper function for easy creation of Cmp<Projection> objects.
  inline Cmp<Projection> pcmp(const Projection& p1, const Projection& p2) {
    return Cmp<Projection>(p1, p2);
  }

  /// Global helper function for easy creation of Cmp<Projection> objects from
  /// two parent projections and their common name for the projection to be compared.
  inline Cmp<Projection> pcmp(const Projection& parent1, const Projection& parent2, const string& pname) {
    return Cmp<Projection>(parent1.getProjection(pname), parent2.getProjection(pname));
  }

  /// Global helper function for easy creation of Cmp<Projection> objects from
  /// two parent projections and their common name for the projection to be compared.
  /// This version takes one parent as a pointer.
  inline Cmp<Projection> pcmp(const Projection* parent1, const Projection& parent2, const string& pname) {
    assert(parent1);
    return Cmp<Projection>(parent1->getProjection(pname), parent2.getProjection(pname));
  }

  /// Global helper function for easy creation of Cmp<Projection> objects from
  /// two parent projections and their common name for the projection to be compared.
  /// This version takes one parent as a pointer.
  inline Cmp<Projection> pcmp(const Projection& parent1, const Projection* parent2, const string& pname) {
    assert(parent2);
    return Cmp<Projection>(parent1.getProjection(pname), parent2->getProjection(pname));
  }

  /// Global helper function for easy creation of Cmp<Projection> objects from
  /// two parent projections and their common name for the projection to be compared.
  inline Cmp<Projection> pcmp(const Projection* parent1, const Projection* parent2, const string& pname) {
    assert(parent1);
    assert(parent2);
    return Cmp<Projection>(parent1->getProjection(pname), parent2->getProjection(pname));
  }


}


#endif