在编译时获取 boost::function arity?
我需要根据 boost::function
对象的数量(参数计数)在 BOOST_PP_IF
语句中做出决定。这可能吗?
boost::function_types::function_arity
做了我正在寻找的事情,但是在运行时;我在编译时需要它。
I need to make a decision in a BOOST_PP_IF
statement based on the arity (parameter count) of a boost::function
object. Is this possible?
boost::function_types::function_arity
does what I'm looking for, but at runtime; I need it at compile time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请注意,这是编译时常量,
您应该从这里开始:
http://www.boost.org/doc/ libs/1_43_0/libs/mpl/doc/index.html
或使用 BOOST_PP_SEQ_FOR_EACH/BOOST_PP_REPEAT_FROM_TO 针对
function_arity::value
生成 if/else 条件note, this is compile time constant
you should start here:
http://www.boost.org/doc/libs/1_43_0/libs/mpl/doc/index.html
or use BOOST_PP_SEQ_FOR_EACH/BOOST_PP_REPEAT_FROM_TO to generate if/else conditions against
function_arity<F>::value
由于某种原因,我的包含内容不断中断,但不在预览中=[
For some reason my includes keep breaking but not in preview =[
如果您需要的只是读取 boost::function 的数量,那么您不需要做那么多工作:
If all you need is to read the arity of a boost::function then you don't need to do that much work: