This file is indexed.

/usr/include/ThePEG/Utilities/AnyReference.h is in libthepeg-dev 1.8.0-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
// -*- C++ -*-
//
// AnyReference.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2007 Leif Lonnblad
// Copyright (C) 2010-2011 Simon Platzer
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
#ifndef ThePEG_AnyReference_H
#define ThePEG_AnyReference_H

#include "ThePEG/Config/ThePEG.h"
#include "Exception.h"

namespace ThePEG {

  /**
   * AnyReference is inspired by boost::any to hold a reference to an
   * object of arbitrary type.
   */
  class AnyReference {

    struct ReferenceHolderBase {

      /**
       * The destructor.
       */
      virtual ~ReferenceHolderBase() {}

      /**
       * Return the type held.
       */
      virtual const std::type_info& type() const = 0;

      /**
       * Clone this reference holder.
       */
      virtual ReferenceHolderBase* clone() const = 0;

    };

    template<class T>
    struct ReferenceHolder 
      : public ReferenceHolderBase {

      /**
       * The reference held.
       */
      T& value;

      /**
       * Static member to initialize the reference.
       */
      static T& init() {
	static T v; return v;
      }

      /**
       * The default constructor
       */
      ReferenceHolder()
	: value(init()) {}

      /**
       * Construct from given reference.
       */
      explicit ReferenceHolder(T& v)
	: value(v) {}

      /**
       * Return the type held.
       */
      virtual const std::type_info& type() const {
	return typeid(T);
      }

      /**
       * Clone this reference holder.
       */
      virtual ReferenceHolderBase* clone() const {
	return new ReferenceHolder(*this);
      }

    };

    /**
     * The reference holder used.
     */
    ReferenceHolderBase* holder;

  public:

    /**
     * The default constructor
     */
    AnyReference()
      : holder(0) {}

    /**
     * The standard constructor
     */
    template<class T>
    AnyReference(T& v)
      : holder(new ReferenceHolder<T>(v)) {}

    /**
     * The copy constructor
     */
    AnyReference(const AnyReference& other)
      : holder(other.holder ? other.holder->clone() : 0) {}

    /**
     * The destructor.
     */
    ~AnyReference() {
      if ( holder ) {
	delete holder; holder = 0;
      }
    }

  public:

    /**
     * Return the type held.
     */
    const std::type_info& type() const { return holder ? holder->type() : typeid(void); }

    /**
     * Return true, if no reference is held.
     */
    bool empty() const { return !holder; }

  public:

    /**
     * Swap the references held.
     */
    AnyReference& swap(AnyReference& other) { 
      std::swap(holder,other.holder); return *this;
    }

    /**
     * Assign from definite type
     */
    template<class T>
    AnyReference& operator=(T& v) {
      AnyReference(v).swap(*this);
      return *this;
    }

    /**
     * Assign from AnyReference
     */
    AnyReference& operator=(AnyReference other) {
      other.swap(*this);
      return *this;
    }

    /**
     * Reset to not keep track of any reference.
     */
    void reset() {
      if ( holder ) delete holder; holder = 0;
    }

  public:

    /**
     * Extract the held reference.
     */
    template<class T>
    T& cast() const {
      if ( !empty() && type() == typeid(T) ) {
	return static_cast<ReferenceHolder<T>*>(holder)->value;
      }
      throw Exception() << "Bad cast in AnyReference" << Exception::abortnow;
      return ReferenceHolder<T>::init();
    }

  };

}

#endif // ThePEG_AnyReference_H