【发布时间】:2011-08-07 08:18:28
【问题描述】:
所以我 use BOOST.EXTENTION 加载模块。我有一个描述每个模块的特殊文件。我从该文件中读取变量。
shared_library m("my_module_name");
// Call a function that returns an int and takes a float parameter.
int result = m.get<int, float>("function_name")(5.0f);
m.close();
对我来说会变成:
shared_library m("my_module_name");
// Call a function that returns an int and takes a float parameter.
int result = m.get<myMap["TYPE_1_IN_STRING_FORM"], myMap["TYPE_2_IN_STRING_FORM"]>("function_name")(5.0f);
m.close();
如何创建这样的地图来映射标准和服装类型?
更新:
可能与variant:
shared_library m("my_module_name");
int result = m.get<boost::variant< int, float, ... other types we want to support >, boost::variant< int, float, ... other types we want to support > >("function_name")(5.0f);
m.close();
可以停下来吗?所以只要我们想要的所有类型都在其中声明,我们就不会关心?
【问题讨论】:
标签: c++ boost types map boost-extension