ho wrapper che invoca funzione template N volte:C++ 11 args variadic con valore di argomento di funzione di default
template <std::uint16_t N, typename F, typename ... Args>
inline typename std::result_of<F && (Args &&...)>::type retry_n(F && f, Args&& ... ax)
{
for (auto i = 0; i < N; ++i)
{
try
{
return std::forward<F>(f)(std::forward<Args>(ax)...);
}
catch (const some_except &e){ /*ignore exception for a while*/ }
}
throw;//re-raise
}
Tutto funziona bene fino a quando mi passa funzione con argomento di default:
int f(int a, int b, int c = 5);
....
retry_n<10>(f, 1, 2); // error C2198: 'bla-bla' : too few arguments for call
Come consentire l'uso dell'argomento predefinito senza specifiche esplicite?
'retry_fn <10> ([] (auto ... x) {return f (x ...);}, 1, 2) ' –
@ ᐅ JohannesSchaub-litb ᐊ sì è ovvia soluzione – Dewfy