在运行时调用函数 [英] Calling Function at runtime

查看:85
本文介绍了在运行时调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在运行时调用arbirary函数,使用arbirary

参数和类型?


BOOST.Bind可以这样做吗?

解决方案

leaf写道:

如何在运行时调用arbirary函数,具有arbirary
参数和类型?

可以BOOST.Bind那样做吗?




任意?以什么方式?你不知道这个函数的类型在

编译时间吗?


你能展示一些代码来展示你想要实现的目标吗?


你能说出你想要解决的问题吗?


Ben Pope

-

我不只是一个数字。对于很多人来说,我被称为字符串...


2006年3月10日,叶写道:

我如何在运行时调用arbirary函数,使用arbirary
参数和类型?




你需要一个仿函数。我见过的最有用的例子来自Andrei

Alexandrescu的书Modern C ++ Design(ISBN 0201704315)。


一些有用的信息在这里:
http://www.codeproject.com/cpp/ genfunctors.asp


-

Simon Elliott http://www.ctsn.co.uk


文章< 11 ****** ****************@i40g2000cwc.googlegroups .com> ;,

" leaf" <广告******** @ gmail.com>写道:

如何在运行时调用arbirary函数,具有arbirary
参数和类型?

可以BOOST.Bind这样做吗? / blockquote>


编号根据您之前的问题,您需要的是一张带有键的地图

是函数签名,值是指针到

的功能。


-

魔术取决于传统和信仰。它不欢迎观察,

也不会通过实验获利。另一方面,科学的经验基于
;它可以通过观察和实验进行校正。


How can i call arbirary functions at runtime, that with arbirary
parameters and types?

Can BOOST.Bind do that?

解决方案

leaf wrote:

How can i call arbirary functions at runtime, that with arbirary
parameters and types?

Can BOOST.Bind do that?



Arbitrary? In what way? Do you not know the type of the function at
compile time?

Can you show some code to demonstrate what you want to achieve?

Can you describe the problem you''re trying to solve?

Ben Pope
--
I''m not just a number. To many, I''m known as a string...


On 10/03/2006, leaf wrote:

How can i call arbirary functions at runtime, that with arbirary
parameters and types?



You need a functor. The most useful example I''ve seen is from Andrei
Alexandrescu''s book "Modern C++ Design (ISBN 0201704315).

Some useful info here:
http://www.codeproject.com/cpp/genfunctors.asp

--
Simon Elliott http://www.ctsn.co.uk


In article <11**********************@i40g2000cwc.googlegroups .com>,
"leaf" <ad********@gmail.com> wrote:

How can i call arbirary functions at runtime, that with arbirary
parameters and types?

Can BOOST.Bind do that?



No. Based on your earlier questions, what you need is a map with the key
being the function signature and the value being a pointer to the
function.

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.


这篇关于在运行时调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆