C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了C这行代码是什么意思?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在一个名为 Selene(一个C 11 Lua包装器)的项目中看到了这个,我在徘徊它的作用?

using Fun = std::function<void()>;
using PFun = std::function<void(Fun)>;

它是类(SELEctor)的私有成员.

周边代码

namespace sel {
class State;
class SELEctor {
private:
    friend class State;
    State &_state;
    using Fun = std::function<void()>;
    using PFun = std::function<void(Fun)>;

    // Traverses the structure up to this element
    Fun _traverse;
    // Pushes this element to the stack
    Fun _get;
    // Sets this element from a function that pushes a value to the
    // stack.
    PFun _put;

    // Functor is stored when the () operator is invoked. The argument
    // is used to inDicate how many return values are expected
    using Functor = std::function<void(int)>;
    mutable std::unique_ptr<Functor> _functor;

    SELEctor(State &s,Fun traverse,Fun get,PFun put)
        : _state(s),_traverse(traversE),_get(get),_put(put),_functor{nullptr} {}

    SELEctor(State &s,const char *Name);

解决方法

它是一个C 11语法,涵盖了typedef功能( and more). @H_675_20@在这种情况下,它创建一个名为Fun的别名,它与std :: function< void()>的类型相同:

using Fun = std::function<void()>; // same as typedef std::function<void()> Fun

这意味着你可以这样做:

void foo() 
{
  std::cout << "foo\n";
}

Fun f = foo; // instead of std::function<void()> f = foo;
f();

同样对于PFun.

大佬总结

以上是大佬教程为你收集整理的C这行代码是什么意思?全部内容,希望文章能够帮你解决C这行代码是什么意思?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。