Questo funziona ...Usa decltype e std :: funzione con lambda
auto x = 4;
typedef decltype(x) x_t;
x_t y = 5;
... e allora perché non fa questo?
int j = 4;
auto func = [&] (int i) { cout << "Hello: i=" << i << " j=" << j << endl;};
typedef decltype(func) lambda_t;
lambda_t func2 = [&] (int i) { cout << "Bye: i=" << i << " j=" << j << endl;};
... e come dovrei dichiarare lambda_t
manualmente utilizzando std :: funzione?
Si può certamente typedef lambda con decltype come quello. –
@ R.MartinhoFernandes implora la domanda perché 'decltype (func)' non restituisce 'std :: function' invece di una inutile spazzatura? –
learnvst
@learnvst: Perché dovrebbe? 'decltype' restituisce il tipo dichiarato, e un lambda è * not * a' std :: function'. Inoltre, 'std :: function' ha implicazioni sulle prestazioni, tra le altre cose, grazie alla cancellazione del tipo. – Xeo