所以我使用 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();
如何创建这样的地图来映射标准和服装类型?
更新:
可能有变体:
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();
能停下来吗?所以只要我们想要的所有类型都在其中声明,我们就不会关心?