mercredi 5 juin 2019

Why is the size of lambda memory not 12?

I came across this issue whilearning lambdas, This was run from Visual Studio 2017 in Debug X86 mode

int main()
{
  int i=0;
  double j=0;
  auto lambda = [i,j]()
    {
      std::cout<<sizeof(j)<<std::endl;
      std::cout<<sizeof(i)<<std::endl;
    };    
    l();
  std::cout<<sizeof(lambda);
}

I was expecting an output of 12(8+4) as in the case both are int it was returning the output as 8(4+4) but instead, it gave me 16

Aucun commentaire:

Enregistrer un commentaire