summary refs log tree commit diff stats
path: root/tests/cpp
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2018-06-10 16:44:49 +0300
committerzah <zahary@gmail.com>2018-06-10 22:27:51 +0300
commit5f2cdcd4fa0f3d5dd0156026c0685aa59d9f7f92 (patch)
tree8645974aba4e3f33afd86f6a8bdb18cf5dccafde /tests/cpp
parent03653ab61e6eed6811c5df0677a2bf2aa722ef9c (diff)
downloadNim-5f2cdcd4fa0f3d5dd0156026c0685aa59d9f7f92.tar.gz
fix #7653
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()
+