mardi 16 août 2016

Lambda Deleter in VC 2013 vs 2015

I am moving some old code from VC 2013 to 2015.

The simplified code below works fine in VC 2013, but fails in 2015 with:

error C2664: 'void main::<lambda_da721648e605a5fd45c9a3fb8c3d06f6>::operator ()(main::D *&) const': cannot convert argument 1 from 'main::D *' to 'main::D *&'

I am not looking for a solution, but for an explanation on what and why changed.


Thank you.

#include <memory>

int main()
{
  class D{};

  auto mydel = []( D*&p ) { delete p; p = 0; };

  std::unique_ptr< D, decltype(mydel) > up( new D );

  return 0;
}

Aucun commentaire:

Enregistrer un commentaire