mercredi 6 novembre 2019

C++ ternary assignment of lambda

Any idea why the following snippet doesn't compile? It complains with an error "error: operands to ?: have different types"

  auto lambda1 = [&](T& arg) {
      ...
  };
  auto lambda2 = [&](T& arg) {
      ...
  };
  auto lambda = condition ? lambda1 : lambda2;

Aucun commentaire:

Enregistrer un commentaire