jeudi 24 août 2017

Ambiguous call to member function for captured this in a lambda

I have encountered an issue when trying to call a member function inside a lambda for a captured this. There is a const and non const version of the function and it is templated on a type.

The following code demonstrates the error:

struct TEST
{
  template <typename T>
  void test() {}

  template <typename T>
  void test() const {}

  TEST()
  {
    [this]()
    {
      test<void>();
    }();
  }
};

I wasn't sure if this behaviour was correct and just an issue with the Microsoft compiler, so I tested the code with gcc and clang in the compiler explorer and they both compiled the code without an error.

Which compiler is displaying the correct behaviour here?

Aucun commentaire:

Enregistrer un commentaire