Can I use (boost) bind with a function template?

后端 未结 2 501
花落未央
花落未央 2020-12-06 17:24

Is it possible to bind arguments to a function template with (boost) bind?

// Define a template function (just a silly example)
template

        
2条回答
  •  难免孤独
    2020-12-06 17:49

    It seems to work if you create a function reference:

    int (&fun)(int, int) = FCall2Templ;
    int res2 = boost::bind(fun, 42, 56)();
    

    Or:

    typedef int (&IntFun)(int, int);
    int res3 = boost::bind(IntFun(FCall2Templ), 42, 56)();
    

    (Tested on GCC)

提交回复
热议问题