我如何用C ++ 11使用语法typedef一个函数指针? [英] How do I typedef a function pointer with the C++11 using syntax?
本文介绍了我如何用C ++ 11使用语法typedef一个函数指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想写这个
typedef void (*FunctionPtr)();
<
using using
. How would I do that?
推荐答案
它有一个类似的语法,除非从指针中删除标识符:
It has a similar syntax, except you remove the identifier from the pointer:
using FunctionPtr = void (*)();
以下是示例
如果你想夺走丑陋,请尝试Xeo建议的内容:
If you want to "take away the uglyness", try what Xeo suggested:
#include <type_traits>
using FunctionPtr = std::add_pointer<void()>::type;
这是另一个演示。
这篇关于我如何用C ++ 11使用语法typedef一个函数指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文