summary refs log tree commit diff stats
path: root/tests/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cpp')
-rw-r--r--tests/cpp/tempty_generic_obj.nim16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/cpp/tempty_generic_obj.nim b/tests/cpp/tempty_generic_obj.nim
index b4c746a30..b61c699f6 100644
--- a/tests/cpp/tempty_generic_obj.nim
+++ b/tests/cpp/tempty_generic_obj.nim
@@ -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()
+