This file is indexed.

/usr/include/dune/common/overloadset.hh is in libdune-common-dev 2.5.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
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_COMMON_OVERLOADSET_HH
#define DUNE_COMMON_OVERLOADSET_HH

#include <utility>
#include <type_traits>

#include <dune/common/std/type_traits.hh>



namespace Dune {

namespace Impl {

  // This overload set derives from
  // all passed functions. Since we
  // cannot do argument pack expansion
  // on using statements this is done recursively.
  template<class F0, class... F>
  class OverloadSet: public OverloadSet<F...>, F0
  {
    using Base = OverloadSet<F...>;
  public:

    template<class FF0, class... FF>
    OverloadSet(FF0&& f0, FF&&... ff) :
      Base(std::forward<FF>(ff)...),
      F0(std::forward<FF0>(f0))
    {}

    // pull in operator() of F0 and of all F... via the base class
    using F0::operator();
    using Base::operator();
  };

  template<class F0>
  class OverloadSet<F0>: public F0
  {
  public:

    template<class FF0>
    OverloadSet(FF0&& f0) :
      F0(std::forward<FF0>(f0))
    {}

    // pull in operator() of F0
    using F0::operator();
  };

} // end namespace Impl



/**
 * \brief Create an overload set
 *
 * \tparam F List of function object types
 * \param f List of function objects
 *
 * This returns an object that contains all
 * operator() implementations of the passed
 * functions. All those are available when
 * calling operator() of the returned object.
 *
 * The returned object derives from
 * those implementations such that it contains
 * all operator() implementations in its
 * overload set. When calling operator()
 * this will select the best overload.
 * If multiple overload are equally good this
 * will lead to ambiguity.
 *
 * Notice that the passed function objects are
 * stored by value and must be copy-constructible.
 */
template<class... F>
auto overload(F&&... f)
{
  return Impl::OverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
}



namespace Impl {

  template<class F0, class... F>
  class OrderedOverloadSet: public OrderedOverloadSet<F...>, F0
  {
    using Base = OrderedOverloadSet<F...>;
  public:

    template<class FF0, class... FF>
    OrderedOverloadSet(FF0&& f0, FF&&... ff) :
      Base(std::forward<FF>(ff)...),
      F0(std::forward<FF0>(f0))
    {}

    // Forward to operator() of F0 if it can be called with the given arguments.
    template<class...  Args,
        std::enable_if_t<Std::is_callable<F0(Args&&...)>::value, int> = 0>
    decltype(auto) operator()(Args&&... args)
    {
      return F0::operator()(std::forward<Args>(args)...);
    }

    // Forward to operator() of base class if F0 cannot be called with the given
    // arguments. In this case the base class will successively try operator()
    // of all F... .
    template<class...  Args,
        std::enable_if_t< not Std::is_callable<F0(Args&&...)>::value, int> = 0>
    decltype(auto) operator()(Args&&... args)
    {
      return Base::operator()(std::forward<Args>(args)...);
    }

  };

  template<class F0>
  class OrderedOverloadSet<F0>: public F0
  {
  public:

    template<class FF0>
    OrderedOverloadSet(FF0&& f0) :
      F0(std::forward<FF0>(f0))
    {}

    // Forward to operator() of F0. If it cannot be called with
    // the given arguments a static assertion will fail.
    template<class...  Args>
    decltype(auto) operator()(Args&&... args)
    {
      static_assert(Std::is_callable<F0(Args&&...)>::value, "No matching overload found in OrderedOverloadSet");
      return F0::operator()(std::forward<Args>(args)...);
    }
  };

} // end namespace Impl



/**
 * \brief Create an ordered overload set
 *
 * \tparam F List of function object types
 * \param f List of function objects
 *
 * This returns an object that contains all
 * operator() implementations of the passed
 * functions. All those are available when
 * calling operator() of the returned object.
 *
 * In contrast to overload() these overloads
 * are ordered in the sense that the first
 * matching overload for the given arguments
 * is selected and later ones are ignored.
 * Hence such a call is never ambiguous.
 *
 * Notice that the passed function objects are
 * stored by value and must be copy-constructible.
 */
template<class... F>
auto orderedOverload(F&&... f)
{
  return Impl::OrderedOverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
}



} // end namespace Dune

#endif // DUNE_COMMON_OVERLOADSET_HH