combinedfunctor.hh
Go to the documentation of this file.00001 #ifndef DUNE_AMG_COMBINEDFUNCTOR_HH
00002 #define DUNE_AMG_COMBINEDFUNCTOR_HH
00003
00004 #include<dune/common/tuples.hh>
00005 namespace Dune
00006 {
00007 namespace Amg
00008 {
00009
00010 template<std::size_t i>
00011 struct ApplyHelper
00012 {
00013 template<class TT, class T>
00014 static void apply(TT tuple, const T& t)
00015 {
00016 get<i-1>(tuple)(t);
00017 ApplyHelper<i-1>::apply(tuple, t);
00018 }
00019 };
00020 template<>
00021 struct ApplyHelper<0>
00022 {
00023 template<class TT, class T>
00024 static void apply(TT tuple, const T& t)
00025 {}
00026 };
00027
00028 template<typename T>
00029 class CombinedFunctor :
00030 public T
00031 {
00032 public:
00033 CombinedFunctor(const T& tuple)
00034 : T(tuple)
00035 {}
00036
00037 template<class T1>
00038 void operator()(const T1& t)
00039 {
00040 ApplyHelper<tuple_size<T>::value>::apply(*this, t);
00041 }
00042 };
00043
00044
00045 }
00046 }
00047 #endif