jeudi 20 octobre 2022

What does " [&]() " mean in C++?

I am reading to an open source project. I am not able to understand what this snippet does ?

EXPORT Result LoaderParse(
    LoaderContext *Cxt, Context **Module,
    const char *Path) {
  return wrap(
      [&]() {
        return fromloa(Cxt)->parse(std::filesystem::absolute(Path));
      },
      [&](auto &&Res) { *Mod = toAST((*Res).release()); }, Cxt,
      Module);
}


template <typename T, typename U, typename... CxtT>
inline Result wrap(T &&Proc, U &&Then, CxtT *...Cxts) noexcept {
  if (isC(Cxts...)) {
    if (auto Res = Proc()) {
      Then(Res);
      return 0;
    } else {
      return 1;
    }
  } else {
    return 2;
  }
}

Can anyone explain me what does [&] do in this case?

Aucun commentaire:

Enregistrer un commentaire