Oh great that's works !
    
    
    template constructFooOtherNestedClass*[T; T1; T2](): FooOtherNestedClass[T, 
T1, T2] =
      implConstructFooOtherNestedClass(typedesc[T], typedesc[T1], typedesc[T2])
    
    proc implConstructFooOtherNestedClass*(T, T1, T2: typedesc): 
FooOtherNestedClass[T, T1, T2] {.
        constructor, importcpp: "Foo<\'*1>::OtherNestedClass<\'*2,\'*3>()",
        header: "typename.hpp".}
    
    
    template constructFooOtherNestedClass*[T; T1; T2](i: cint): 
FooOtherNestedClass[T, T1, T2] =
      implConstructFooOtherNestedClass(typedesc[T], typedesc[T1], typedesc[T2], 
i)
    
    proc implConstructFooOtherNestedClass*(T, T1, T2: typedesc, i: cint): 
FooOtherNestedClass[T, T1, T2] {.
        constructor, importcpp: "###Foo<\'*1>::OtherNestedClass<\'*2,\'*3>(@)", 
#The ### is to avoid the three first argumenta being passed to the constructor
        header: "typename.hpp".}
    

but too bad there is a bug preventing me from using it :/ It seems that we 
cannot overload templates with generic parameters: 
    
    
    var nc = constructFooOtherNestedClass[float, float64, int8]()
    

gives me:
    
    
     Error: type mismatch: got ()
    but expected one of:
    template constructFooOtherNestedClass[T; T1; T2](i: cint): 
FooOtherNestedClass[T, T1,
        T2]
    

test case: 
    
    
    #this works
    template test() =
        echo "no param"
    
    template test(i: int)=
        echo "in param"
    
    test()
    test(1)
    
    #but this not
    template test[T]() =
        echo "no param"
    
    template test[T](i: int)=
        echo "in param"
    
    test[int]()
    test[int](1)
    

[https://play.nim-lang.org/?gist=f92e0ddcce67df8ca604a253ead94e21](https://play.nim-lang.org/?gist=f92e0ddcce67df8ca604a253ead94e21)

Reply via email to