fix #7653
This commit is contained in:
parent
03653ab61e
commit
5f2cdcd4fa
4 changed files with 34 additions and 13 deletions
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
discard """
|
||||
output: '''42'''
|
||||
output: "42\n42"
|
||||
"""
|
||||
|
||||
type
|
||||
Foo[N: static[int]] = object
|
||||
|
||||
proc foo[N](x: Foo[N]) =
|
||||
let n = N
|
||||
echo N
|
||||
echo n
|
||||
|
||||
var f1: Foo[42]
|
||||
f1.foo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue