Hi,

I have a little question. I order to wrap some C++ code (and add a feature to 
c2nim), I have to write something like this: 
    
    
    proc constructFoo*[T1, T2](): Foo[T1, T2] =
      result = implConstructFoo(T1, T2)
    
    proc implConstructFoo*(T1: typedesc, T2: typedesc): Foo[T1, T2] 
{.constructor, importcpp: "Foo<\'1, \'2>(@)",
                                   header: "typename.hpp".}
    

This allows me to wrap C++ constructors/destrucotrs/methods that depends on 
templates.

The template parameters have to be passed as arguments to the functions, as 'i 
refers to the ith parameter type and not the ith generic type.

What I'd like to do now is to make constructFoo a template, so I'm sure that it 
is inlined and do not cost the user any overhead.

Something like this: 
    
    
    template constructFoo*[T1, T2](): untyped =
      implConstructFoo(T1, T2)
    
    proc implConstructFoo*(T1: typedesc, T2: typedesc): Foo[T1, T2] 
{.constructor, importcpp: "Foo<\'1, \'2>(@)",
                                   header: "typename.hpp".}
    

But I get an error: 
    
    
    Error: type mismatch: got (float, float)
    but expected one of:
    proc implConstructFoo(T1, T2: typedesc): Foo[T1, T2]
    

thanks for your help

Reply via email to