tempty_generic_obj.nim 448 B

1234567891011121314151617181920212223
  1. discard """
  2. cmd: "nim cpp $file"
  3. output: '''int
  4. float'''
  5. """
  6. import typetraits
  7. # bug #4625
  8. type
  9. Vector {.importcpp: "std::vector<'0 >", header: "vector".} [T] = object
  10. proc initVector[T](): Vector[T] {.importcpp: "'0(@)", header: "vector", constructor.}
  11. proc doSomething[T](v: var Vector[T]) =
  12. echo T.name
  13. var v = initVector[int]()
  14. v.doSomething()
  15. var vf = initVector[float]()
  16. vf.doSomething() # Nim uses doSomething[int] here in C++