Commit ad6a52fb authored by Christian Godenschwager's avatar Christian Godenschwager
Browse files

Merge branch 'variadic' into 'master'

Use variadic template in MakeBlockDataInitFunction

See merge request walberla/walberla!111
parents 97fd82d4 1e3f9d83
......@@ -34,119 +34,19 @@ namespace domain_decomposition {
/// \cond internal
namespace internal
{
template<class T>
T * newFunc( const IBlock* const ) {
return new T();
template<class T, typename... Args>
T * newFunc( const IBlock* const, Args&... args ) {
return new T(args...);
}
template<class T, class P1>
T * newFunc( const IBlock* const , const P1 & p1 ) {
return new T(p1);
}
template<class T, class P1, class P2>
T * newFunc( const IBlock* const , const P1 & p1, const P2 & p2 ) {
return new T(p1, p2);
}
template<class T, class P1, class P2, class P3>
T * newFunc( const IBlock* const , const P1 & p1, const P2 & p2, const P3 & p3 ) {
return new T(p1, p2, p3);
}
template<class T, class P1, class P2, class P3, class P4>
T * newFunc( const IBlock* const , const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4 ) {
return new T(p1, p2, p3, p4);
}
template<class T, class P1, class P2, class P3, class P4, class P5>
T * newFunc( const IBlock* const , const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5 ) {
return new T(p1, p2, p3, p4, p5);
}
template<class T, class P1, class P2, class P3, class P4, class P5, class P6>
T * newFunc( const IBlock* const , const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5, const P6 & p6 ) {
return new T(p1, p2, p3, p4, p5, p6);
}
template<class T, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
T * newFunc( const IBlock* const , const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5, const P6 & p6, const P7 & p7 ) {
return new T(p1, p2, p3, p4, p5, p6,p7);
}
template<class T, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
T * newFunc( const IBlock* const , const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5, const P6 & p6, const P7 & p7, const P8 & p8 ) {
return new T(p1, p2, p3, p4, p5, p6, p7,p8 );
}
template<class T, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
T * newFunc( const IBlock* const , const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5, const P6 & p6, const P7 & p7, const P8 & p8, const P9 & p9 ) {
return new T(p1, p2, p3, p4, p5, p6, p7,p8, p9 );
}
} // namespace internal
/// \endcond
template<class T>
std::function< T* ( const IBlock* const block ) >
makeBlockDataInitFunction() {
return std::bind( internal::newFunc<T>, std::placeholders::_1);
}
template<class T, class P1>
std::function< T* ( const IBlock* const block ) >
makeBlockDataInitFunction(const P1 & p1) {
return std::bind( internal::newFunc<T,P1>, std::placeholders::_1,p1);
}
template<class T, class P1, class P2>
std::function< T* ( const IBlock* const block ) >
makeBlockDataInitFunction(const P1 & p1, const P2 & p2) {
return std::bind( internal::newFunc<T,P1,P2>, std::placeholders::_1,p1,p2);
}
template<class T, class P1, class P2, class P3>
std::function< T* ( const IBlock* const block ) >
makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3) {
return std::bind( internal::newFunc<T,P1,P2,P3>, std::placeholders::_1,p1,p2,p3);
}
template<class T, class P1, class P2, class P3, class P4>
std::function< T* ( const IBlock* const block ) >
makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4) {
return std::bind( internal::newFunc<T,P1,P2,P3,P4>, std::placeholders::_1,p1,p2,p3,p4);
}
template<class T, class P1, class P2, class P3, class P4, class P5>
std::function< T* ( const IBlock* const block ) >
makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5) {
return std::bind( internal::newFunc<T,P1,P2,P3,P4,P5>, std::placeholders::_1,p1,p2,p3,p4,p5);
}
template<class T, class P1, class P2, class P3, class P4, class P5, class P6>
std::function< T* ( const IBlock* const block ) >
makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5, const P6 & p6) {
return std::bind( internal::newFunc<T,P1,P2,P3,P4,P5,P6>, std::placeholders::_1,p1,p2,p3,p4,p5,p6);
}
template<class T, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
std::function< T* ( const IBlock* const block ) >
makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5, const P6 & p6, const P7 & p7) {
return std::bind( internal::newFunc<T,P1,P2,P3,P4,P5,P6,P7>, std::placeholders::_1,p1,p2,p3,p4,p5,p6,p7);
}
template<class T, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
std::function< T* ( const IBlock* const block ) >
makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5, const P6 & p6, const P7 & p7, const P8 & p8) {
return std::bind( internal::newFunc<T,P1,P2,P3,P4,P5,P6,P7,P8>, std::placeholders::_1,p1,p2,p3,p4,p5,p6,p7,p8);
}
template<class T, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
template<class T, typename... Args>
std::function< T* ( const IBlock* const block ) >
makeBlockDataInitFunction(const P1 & p1, const P2 & p2, const P3 & p3, const P4 & p4, const P5 & p5, const P6 & p6, const P7 & p7, const P8 & p8, const P9 & p9) {
return std::bind( internal::newFunc<T,P1,P2,P3,P4,P5,P6,P7,P8,P9>, std::placeholders::_1,p1,p2,p3,p4,p5,p6,p7,p8,p9);
makeBlockDataInitFunction(Args&&... args) {
return std::bind( internal::newFunc<T,Args...>, std::placeholders::_1, std::forward<Args>(args)... );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment