dimanche 22 février 2015

c++11 typedef function pointer with trailing return type

I have been trying to clean up an inherited code base. It makes extensive use of template functions that include a trailing return type. It also includes a lot of function pointers to non-templated, non-member functions. During the clean up I discovered that code equivalent to the following works under Visual Studio 2013:



#define function typedef auto

function Kernel (int, int) -> int;

struct Transform
{
Kernel* kernel;
char* description;
};

Transform add_transform { add, "add" };


Is this typedef valid in the C++11 standard?


While I personally avoid #defines like the plague (especially when used to create a new language feature like these 'functions'), given the prevalence of trailing return types in the project the team feels this would make the code base significantly more readable.


Aucun commentaire:

Enregistrer un commentaire