summary refs log tree commit diff stats
path: root/tests/cpp
diff options
context:
space:
mode:
authorcooldome <ariabushenko@bk.ru>2018-06-26 23:33:34 +0100
committercooldome <ariabushenko@bk.ru>2018-06-26 23:33:34 +0100
commit34170db96308c367357ece15404815727bce223a (patch)
tree0461d115e39feff0b5ea855fb56f9882ce1eba2c /tests/cpp
parent0b709fb916923b0d5e9eab06fc8766e46e63d955 (diff)
parent19ea3a70d2d6d404235e0f5250d6b681d56903a5 (diff)
downloadNim-34170db96308c367357ece15404815727bce223a.tar.gz
Merge branch 'devel' into Fixes-7845
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()
+
span> ^
734eef7c ^
dff1abb2 ^
734eef7c ^

dff1abb2 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18