I have the following code where I initialize a table of function pointers. The table is used when input file is parsed.
class TorchModule { ... };
class TorchLinear : public TorchModule { ... };
class TorchView : public TorchModule { ... };
...
typedef std::shared_ptr<const TorchModule> ( *load_function )( File* file );
using table_type = std::map< std::string, load_function > table_type;
table_type load_Object = {
{"nn.Linear", &TorchLinear::load },
{"nn.View" , &TorchView ::load }
};
How can I update the code if the base class TorchModule is template class.
template<MODE mode>
class TorchModule { ... };
template<MODE mode>
class TorchLinear : public TorchModule<mode> { ... };
template<MODE mode>
class TorchView : public TorchModule<mode> { ... };