summary refs log tree commit diff stats
path: root/tests/cpp/tempty_generic_obj.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cpp/tempty_generic_obj.nim')
-rw-r--r--tests/cpp/tempty_generic_obj.nim11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/cpp/tempty_generic_obj.nim b/tests/cpp/tempty_generic_obj.nim
index b61c699f6..d05a82f9a 100644
--- a/tests/cpp/tempty_generic_obj.nim
+++ b/tests/cpp/tempty_generic_obj.nim
@@ -8,7 +8,7 @@ import typetraits
 
 # bug #4625
 type
-  Vector {.importcpp: "std::vector<'0 >", header: "vector".} [T] = object
+  Vector[T] {.importcpp: "std::vector<'0 >", header: "vector".} = object
 
 proc initVector[T](): Vector[T] {.importcpp: "'0(@)", header: "vector", constructor.}
 
@@ -24,7 +24,7 @@ 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
+type VectorAlt*[T] {.importcpp: "std::vector", header: "<vector>", nodecl.} = object
 proc mkVector*[T]: VectorAlt[T] {.importcpp: "std::vector<'*0>()", header: "<vector>", constructor, nodecl.}
 
 proc foo(): VectorAlt[cint] =
@@ -36,3 +36,10 @@ proc bar(): VectorAlt[cstring] =
 var x = foo()
 var y = bar()
 
+proc init[T; Self: Vector[T]](_: typedesc[Self], n: csize): Vector[T]
+  {.importcpp: "std::vector<'*0>(@)", header: "<vector>", constructor, nodecl.}
+proc size[T](x: Vector[T]): csize
+  {.importcpp: "#.size()", header: "<vector>", nodecl.}
+
+var z = Vector[int16].init(32)
+assert z.size == 32