1#ifndef __DUNE_ACFEM_COMMON_TUPLETHINGS_HH__
2#define __DUNE_ACFEM_COMMON_TUPLETHINGS_HH__
5#include <dune/common/fvector.hh>
6#include <dune/fem/storage/subvector.hh>
33 template<
class... Containers>
36 using ContainerTupleType = std::tuple<Containers&...>;
39 tupleSize = std::tuple_size<ContainerTupleType>::value
42 : containers_(containers...)
46 : containers_(other.containers_)
50 template<
class Data,
class =
void>
51 struct ConstValueTraits
57 template<
class Data,
class =
void>
64 template<
class Base,
class Mapper>
65 struct ConstValueTraits<Fem::SubVector<Base, Mapper>, void>
68 typedef Fem::SubVector<Base, Mapper> DataType;
69 typedef typename DenseMatVecTraits<DataType>::value_type ValueType;
72 typedef FieldVector<ValueType, size> type;
79 template<
class Base,
class Mapper>
80 struct ValueTraits<Fem::SubVector<Base, Mapper>, void>
82 typedef Fem::SubVector<Base, Mapper> type;
89 decltype(std::declval<Containers>()[0])> >::type...> ValueType;
93 typename ConstValueTraits<
95 decltype(std::declval<const Containers>()[0])> >::type...> ConstValueType;
100 template<
class Tuple,
size_t... Is>
101 auto mutableValueTuple(
size_t idx,
const Tuple& tuple, std::index_sequence<Is...>)
103 return ValueType(std::get<Is>(tuple)[idx]...);
105 template<
class Tuple,
size_t... Is>
106 auto valueTuple(
size_t idx,
const Tuple& tuple, std::index_sequence<Is...>)
const
108 return std::make_tuple(std::get<Is>(tuple)[idx]...);
111 ValueType operator[](
size_t idx)
113 return mutableValueTuple(idx, containers_, std::make_index_sequence<tupleSize>{});
116 const ConstValueType operator[](
size_t idx)
const
118 return valueTuple(idx, containers_, std::make_index_sequence<tupleSize>{});
121 ContainerTupleType containers_;
Create a tuple of values from a tuple of containers.
Definition: containertuple.hh:35
constexpr std::size_t size()
Gives the number of elements in tuple-likes and std::integer_sequence.
Definition: size.hh:73