dimanche 22 juillet 2018

Ability to multiply two parameter packs in C++ 11 in dot product fashion via variadic templates

template<class...A, class...B> void func(A...arg1,int sz1, int sz2, B...arg2)
{
std::cout << "sizeof parameter pack for A = " << sizeof...(arg1) << std::endl;
std::cout << "sizeof parameter pack for B = " << sizeof...(arg2) << std::endl;
}

using namespace std;

int main(void)
{
   func<int,int,int,int>(1,2,3,4,4,4,5,6,7,8);

}

My question is how can i peel the first parameter of each of these packs and multiply them and then sum them with recursive call to reduced parameter pack of both the packs.

Esentially I want to implement : SUM[A[i] * B[i])

Aucun commentaire:

Enregistrer un commentaire