30 #ifndef SACADO_TEMPLATE_CONTAINER_HPP
31 #define SACADO_TEMPLATE_CONTAINER_HPP
36 #ifdef HAVE_SACADO_CXX11
54 template <
typename TypeSeq,
56 typename Iter1 =
typename mpl::begin<TypeSeq>::type,
57 typename Iter2 =
typename mpl::end<TypeSeq>::type>
64 typename Iter1 =
typename mpl::begin<TypeSeq>::type,
65 typename Iter2 =
typename mpl::end<TypeSeq>::type,
66 typename Enabled =
void>
95 template <
typename TypeSeq,
typename ObjectT>
96 class TemplateContainer {
99 typedef Impl::TupleSeq<TypeSeq, ObjectT> tuple_type;
102 template <
typename BuilderOpT>
105 const BuilderOpT& builder;
106 BuildObject(tuple_type& objects_,
107 const BuilderOpT& builder_) :
108 objects(objects_), builder(builder_) {}
109 template <
typename T>
void operator()(
T x)
const {
110 Impl::GetTupleSeq<T,TypeSeq,ObjectT>::apply(objects) = builder(x);
117 typedef TypeSeq types;
120 struct DefaultBuilderOp {
131 TemplateContainer() {}
134 ~TemplateContainer() {}
139 return Impl::GetTupleSeq<T,TypeSeq,ObjectT>::apply(objects);
145 return Impl::GetTupleSeq<T,TypeSeq,ObjectT>::apply(objects);
149 template <
typename BuilderOpT = DefaultBuilderOp>
150 void build(
const BuilderOpT& builder) {
152 BuildObject<BuilderOpT>(objects,builder));
164 template <
typename TypeSeq,
typename ObjectT,
typename FunctorT>
165 void container_for_each(TemplateContainer<TypeSeq,ObjectT>& container,
166 const FunctorT& op) {
167 typedef TemplateContainer<TypeSeq,ObjectT> Container;
173 template <
typename TypeSeq,
typename ObjectT,
typename FunctorT>
174 void container_for_each_no_kokkos(TemplateContainer<TypeSeq,ObjectT>& container,
175 const FunctorT& op) {
176 typedef TemplateContainer<TypeSeq,ObjectT> Container;
184 template <
typename TypeSeq,
typename ObjectT>
185 struct begin< TemplateContainer<TypeSeq,ObjectT> > {
186 typedef typename begin<TypeSeq>::type type;
189 template <
typename TypeSeq,
typename ObjectT>
190 struct end< TemplateContainer<TypeSeq,ObjectT> > {
191 typedef typename end<TypeSeq>::type type;
199 template <
typename TypeSeq,
204 TupleSeq<TypeSeq, ObjectT, typename mpl::next<Iter1>::type, Iter2>
206 typedef typename mpl::apply<ObjectT,
207 typename mpl::deref<Iter1>::type>::type type;
211 template <
typename TypeSeq,
214 struct TupleSeq<TypeSeq, ObjectT, Iter1, Iter1> {};
217 template <
typename T,
223 struct GetTupleSeq {};
225 template <
typename T,
230 struct GetTupleSeq<
T,
235 typename mpl::enable_if_c<
236 mpl::is_same< T, typename mpl::deref<Iter1>::type
239 static typename TupleSeq<TypeSeq,ObjectT,Iter1,Iter2>::type&
240 apply(TupleSeq<TypeSeq,ObjectT,Iter1,Iter2>& t) {
244 static const typename TupleSeq<TypeSeq,ObjectT,Iter1,Iter2>::type&
245 apply(
const TupleSeq<TypeSeq,ObjectT,Iter1,Iter2>& t) {
250 template <
typename T,
255 struct GetTupleSeq<
T,
260 typename mpl::enable_if_c<
261 !mpl::is_same< T, typename mpl::deref<Iter1>::type
264 GetTupleSeq< T, TypeSeq, ObjectT, typename mpl::next<Iter1>::type, Iter2>
267 template <
typename T,
271 struct GetTupleSeq<
T, TypeSeq, ObjectT, Iter1, Iter1,
void> {};
F::template apply< A1, A2, A3, A4, A5 >::type type