可以从匹配的函数typedef干净地生成函数指针typedef吗?
// Can I define fx_pt in terms of fx_t without duplicating the signature?
// Does decltype allow for any new sort of trick here?
using fx_t = char(int, char, std::vector<float> const &);
using fxp_t = char(*)(int, char, std::vector<float> const &);
// Using function typedef to enforce interface for declarations and definitions.
fx_t foo, bar, baz;
char foo(int) { /* ... */ }
// Using fp typedef elsewhere as normal.
fxp_t whatever{bar};
whatever(99);
我从未期望函数(指针)typedef语法对我来说是完全直观的,但我无法确定消除重复代码是否可行。
这可能与在类/基元类型def和类/基指针类型def之间转换的更大问题有关,我记得听说它们在。。。