如何从函数/类接收map

| 如何从这样的功能接收“ 0”? 所以我有
template <class BaseClass, class ConstructorType>
map<string, factory<BaseClass, ConstructorType> > get_factories (shared_library & lib) {
    type_map lib_types;
    if (!lib.call(lib_types)) {
        cerr << \"Types map not found!\" << endl;

    }

    map<string, factory<BaseClass, ConstructorType> >& lib_factories(lib_types.get());
    if (lib_factories.empty()) {
        cerr << \"Producers not found!\" << endl;

    }
    return lib_factories;

}
我尝试通过以下方式获得其价值:
map<string, factory<PublicProducerPrototype, int> > producer_factories();
producer_factories = get_factories<PublicProducerPrototype, int>(simple_producer);
我尝试为自己概括/简化一些boost.extension方法。 那么如何正确接收receive3ѭ呢? 如何正确初始化链接或如何不返回链接而是返回真实对象? (对不起,C ++ nube)     
已邀请:
如果您需要对地图的引用,则应将函数声明为返回引用,而不是值:
template <class BaseClass, class ConstructorType>
map<string, factory<BaseClass, ConstructorType> >& get_factories (...
当然,这假定由
lib_types.get()
返回的参考可以安全地作为参考传递出去。     

要回复问题请先登录注册