mardi 31 octobre 2017

Alias for a lambda

The ISO C++ FAQ (http://ift.tt/2z0JVDP, "Template aliases") quotes the following example:

using P = [](double)->void; // using plus suffix return type

I get an error trying to compile this with g++ -std=c++11:

error: expected type-specifier before ‘[’ token

What should the correct syntax be? If I do

auto p = [](double)->void {};

p gets deduced to be either <lambda(double)> or main()::<lambda(double)>, depending on the scope. However, I can't then do

using P = <lambda(double)>;

as that also gives an error:

expected type-specifier before ‘<’ token

Aucun commentaire:

Enregistrer un commentaire