i've made my variadic meta template work (take any number of int args)
cout << findBestSum<4,5,6,3,7,20,3,50,1,-1,5>::result << endl; //outputs 103 which is good
now i meet a problem of passing a runtime input to this template, for example the standard argv (after converting it to int of course), as it is a pointer, and pointers don't exist in compile-time calculations.
is there a way to extract / expand / parse the input array as separate arguments into the template?
i could of course do something like
findBestSum<arr[0],arr[1],arr[2]>::result
if i knew the number of arguments overhead, but i don't. the user can even input a million numbers.
p.s. just reminding, i can't do it this way: findBestSum<arr>::result
because it is a pointer!! no addresses are assigned at compile-time
Aucun commentaire:
Enregistrer un commentaire