For [very long 
reasons](https://pytorch.org/tutorials/advanced/cpp_frontend.html#module-ownership)
 I'd like to be able to generate C++ constructor with initialization list.

The ultimate goal is being able to inherit from a C++ class like so: 
    
    
    ++
    struct Net : torch::nn::Module {
      Net(int64_t N, int64_t M)
        : linear(register_module("linear", torch::nn::Linear(N, M)))
      { }
      torch::nn::Linear linear;
    };
    
    
    Run

AFAIK for C++ inheritance we just need the pure and inheritable pragma so that 
Nim doesn't add its own runtime typeinfo: 
    
    
    type
      Module* {.pure, inheritable, importcpp: "torch::nn::Module".} = object
    
    
    Run

but the initialization list constructor eludes me. Here is an example with less 
domain-specific noise:
    
    
    +++
    class MyClass {
    public:
        
        MyClass() : m_classID(-1), m_userdata(0) {
        }
        
        int m_classID;
        void *m_userdata;
    };
    
    
    Run

Reply via email to