Domanda

Today I checked out Stroustrup's C++11 FAQ (modified April 7, 2013) and saw this at the end of the type-alias section:

typedef void (*PFD)(double);    // C style
using PF = void (*)(double);    // using plus C-style type
using P = [](double)->void;     // using plus suffix return type

where a lambda introducer is used to start a general function type expression that uses a suffix-style return type. Is this official, or a dropped beta/wish-list feature? If it's official, how would it work for non-static member functions?

È stato utile?

Soluzione

using P = [](double)->void;

is not official. Bjarne is known to be a bit careless in his FAQs.

What does work, however, are the following:

using P1 = auto(double) -> void;
using P2 = auto(*)(double) -> void;

Where P1 is a function type, and P2 is a function-pointer type. Maybe that was his intention.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top