This file is indexed.

/usr/include/trilinos/Sacado_TemplateContainer.hpp is in libtrilinos-sacado-dev 12.12.1-5.

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
// @HEADER
// ***********************************************************************
//
//                           Sacado Package
//                 Copyright (2006) Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
// USA
// Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
// (etphipp@sandia.gov).
//
// ***********************************************************************
// @HEADER

#ifndef SACADO_TEMPLATE_CONTAINER_HPP
#define SACADO_TEMPLATE_CONTAINER_HPP

// While this code does not directly use C++11 features, it uses mpl::vector,
// which does
#include "Sacado_ConfigDefs.h"
#ifdef HAVE_SACADO_CXX11

#include "Sacado_mpl_size.hpp"
#include "Sacado_mpl_find.hpp"
#include "Sacado_mpl_for_each.hpp"
#include "Sacado_mpl_apply.hpp"
#include "Sacado_mpl_begin.hpp"
#include "Sacado_mpl_end.hpp"
#include "Sacado_mpl_deref.hpp"
#include "Sacado_mpl_next.hpp"
#include "Sacado_mpl_enable_if.hpp"
#include "Sacado_mpl_is_same.hpp"

namespace Sacado {

  namespace Impl {

    // Forward declaration
    template <typename TypeSeq,
              typename ObjectT,
              typename Iter1 = typename mpl::begin<TypeSeq>::type,
              typename Iter2 =typename  mpl::end<TypeSeq>::type>
    struct TupleSeq;

    // Forward declaration
    template <typename T,
              typename TypeSeq,
              typename ObjectT,
              typename Iter1 = typename mpl::begin<TypeSeq>::type,
              typename Iter2 = typename mpl::end<TypeSeq>::type,
              typename Enabled = void>
    struct GetTupleSeq;

  } // namespace Impl


  //! Container class to manager template instantiations of a template class
  /*!
   * This class provides a generic container class for managing multiple
   * instantiations of a class ObjectT<T> with the values of T specified
   * through a type sequence.  Objects of type ObjectT<T> must have value
   * semantics, be default constructable and copyable/assignable (for objects
   * that don't satisfy these requirements, one would typically wrap them in
   * a (smart) pointer.  Methods are provided to access the object of type
   * ObjectT<T> for a given type T, as well as initialize them.  One would
   * typically operate on the contained objects using mpl::for_each(), e.g.,
   *
   *    template <class T> class MyClass;
   *    typedef mpl::vector< double, Fad::DFad<double> > MyTypes;
   *    typedef TemplateContainer< MyTypes, MyClass<_> > MyObjects;
   *    MyObjects myObjects;
   *    mpl::for_each<MyObjects>([](auto x) {
   *       typedef decltype(x) T;
   *       myObjects.get<T>() = T;
   *    });
   *
   * (Note:  This requires generalized lambda's introduced in C++14.  For
   * C++11, provide a functor that implements the lambda body).
   */
  template <typename TypeSeq, typename ObjectT>
  class TemplateContainer {

    //! Our container for storing each object
    typedef Impl::TupleSeq<TypeSeq, ObjectT> tuple_type;

    //! Helper class for building objects in container
    template <typename BuilderOpT>
    struct BuildObject {
      tuple_type& objects;
      const BuilderOpT& builder;
      BuildObject(tuple_type& objects_,
                  const BuilderOpT& builder_) :
        objects(objects_), builder(builder_) {}
      template <typename T> void operator()(T x) const {
        Impl::GetTupleSeq<T,TypeSeq,ObjectT>::apply(objects) = builder(x);
      }
    };

  public:

    //! Type sequence containing template types
    typedef TypeSeq types;

    //! The default builder class for building objects for each ScalarT
    struct DefaultBuilderOp {

      //! Returns a new object of type ObjectT<ScalarT>
      template<class T>
      typename Sacado::mpl::apply<ObjectT,T>::type operator() (T) const {
        return typename Sacado::mpl::apply<ObjectT,T>::type();
      }

    };

    //! Default constructor
    TemplateContainer() {}

    //! Destructor
    ~TemplateContainer() {}

    //! Get object corrensponding ObjectT<T>
    template<typename T>
    typename Sacado::mpl::apply<ObjectT,T>::type& get() {
      return Impl::GetTupleSeq<T,TypeSeq,ObjectT>::apply(objects);
    }

    //! Get object corrensponding ObjectT<T>
    template<typename T>
    const typename Sacado::mpl::apply<ObjectT,T>::type& get() const  {
      return Impl::GetTupleSeq<T,TypeSeq,ObjectT>::apply(objects);
    }

    //! Build objects for each type T
    template <typename BuilderOpT = DefaultBuilderOp>
    void build(const BuilderOpT& builder) {
      Sacado::mpl::for_each_no_kokkos<TypeSeq>(
        BuildObject<BuilderOpT>(objects,builder));
    }

  private:

    //! Stores type of objects of each type
    tuple_type objects;

  };

  // Wrap call to mpl::for_each so you don't have to specify the container
  // or type sequence
  template <typename TypeSeq, typename ObjectT, typename FunctorT>
  void container_for_each(TemplateContainer<TypeSeq,ObjectT>& container,
                          const FunctorT& op) {
    typedef TemplateContainer<TypeSeq,ObjectT> Container;
    Sacado::mpl::for_each<Container> f(op);
  }

  // Wrap call to mpl::for_each so you don't have to specify the container
  // or type sequence
  template <typename TypeSeq, typename ObjectT, typename FunctorT>
  void container_for_each_no_kokkos(TemplateContainer<TypeSeq,ObjectT>& container,
                                    const FunctorT& op) {
    typedef TemplateContainer<TypeSeq,ObjectT> Container;
    Sacado::mpl::for_each_no_kokkos<Container> f(op);
  }

  namespace mpl {

    // Give TemplateContainer begin<> and end<> iterators for for_each

    template <typename TypeSeq, typename ObjectT>
    struct begin< TemplateContainer<TypeSeq,ObjectT> > {
      typedef typename begin<TypeSeq>::type type;
    };

    template <typename TypeSeq, typename ObjectT>
    struct end< TemplateContainer<TypeSeq,ObjectT> > {
      typedef typename end<TypeSeq>::type type;
    };

  }

  namespace Impl {

    // Container class to store our tuple sequence
    template <typename TypeSeq,
              typename ObjectT,
              typename Iter1,
              typename Iter2>
    struct TupleSeq :
      TupleSeq<TypeSeq, ObjectT, typename mpl::next<Iter1>::type, Iter2>
    {
      typedef typename mpl::apply<ObjectT,
                                  typename mpl::deref<Iter1>::type>::type type;
      type tail;
    };

    template <typename TypeSeq,
              typename ObjectT,
              typename Iter1>
    struct TupleSeq<TypeSeq, ObjectT, Iter1, Iter1> {};

    // Helper class to get a value out of the tuple sequence from a given type
    template <typename T,
              typename TypeSeq,
              typename ObjectT,
              typename Iter1,
              typename Iter2,
              typename Enabled>
    struct GetTupleSeq {};

    template <typename T,
              typename TypeSeq,
              typename ObjectT,
              typename Iter1,
              typename Iter2>
    struct GetTupleSeq< T,
                        TypeSeq,
                        ObjectT,
                        Iter1,
                        Iter2,
                        typename mpl::enable_if_c<
                          mpl::is_same< T, typename mpl::deref<Iter1>::type
                                        >::value
                          >::type > {
      static typename TupleSeq<TypeSeq,ObjectT,Iter1,Iter2>::type&
      apply(TupleSeq<TypeSeq,ObjectT,Iter1,Iter2>& t) {
        return t.tail;
      }

      static const typename TupleSeq<TypeSeq,ObjectT,Iter1,Iter2>::type&
      apply(const TupleSeq<TypeSeq,ObjectT,Iter1,Iter2>& t) {
        return t.tail;
      }
    };

    template <typename T,
              typename TypeSeq,
              typename ObjectT,
              typename Iter1,
              typename Iter2>
    struct GetTupleSeq< T,
                        TypeSeq,
                        ObjectT,
                        Iter1,
                        Iter2,
                        typename mpl::enable_if_c<
                          !mpl::is_same< T, typename mpl::deref<Iter1>::type
                                         >::value
                          >::type > :
      GetTupleSeq< T, TypeSeq, ObjectT, typename mpl::next<Iter1>::type, Iter2>
    {};

    template <typename T,
              typename TypeSeq,
              typename ObjectT,
              typename Iter1>
    struct GetTupleSeq< T, TypeSeq, ObjectT, Iter1, Iter1, void> {};


  } // namespace Impl

}

#endif
#endif