This commit is contained in:
Zahary Karadjov
2018-06-10 16:44:49 +03:00
committed by zah
parent 03653ab61e
commit 5f2cdcd4fa
4 changed files with 34 additions and 13 deletions

View File

@@ -20,3 +20,19 @@ v.doSomething()
var vf = initVector[float]()
vf.doSomething() # Nim uses doSomething[int] here in C++
# Alternative definition:
# https://github.com/nim-lang/Nim/issues/7653
type VectorAlt* {.importcpp: "std::vector", header: "<vector>", nodecl.} [T] = object
proc mkVector*[T]: VectorAlt[T] {.importcpp: "std::vector<'*0>()", header: "<vector>", constructor, nodecl.}
proc foo(): VectorAlt[cint] =
mkVector[cint]()
proc bar(): VectorAlt[cstring] =
mkVector[cstring]()
var x = foo()
var y = bar()