Skip to content

Commit

Permalink
closes #10219; adds a test case (#23370)
Browse files Browse the repository at this point in the history
closes #10219
  • Loading branch information
ringabout committed Mar 5, 2024
1 parent e217bb2 commit d373d30
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/cpp/torc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,23 @@ proc asVector*[T](t: T): EnumVector[T] =
# N_NIMCALL(std::vector<> , asvector_106028_3197418230)(SomeEnum t0)

discard asVector(SomeEnum.A)


block: # bug #10219
type
Vector[T] {.importcpp: "std::vector", header: "vector".} = object

proc initVector[T](n: csize_t): Vector[T]
{.importcpp: "std::vector<'*0>(@)", header: "vector".}

proc unsafeIndex[T](this: var Vector[T], i: csize_t): var T
{.importcpp: "#[#]", header: "vector".}

proc `[]`[T](this: var Vector[T], i: Natural): var T {.inline, noinit.} =
when compileOption("boundChecks"):
# this.checkIndex i
discard
result = this.unsafeIndex(csize_t(i))

var v1 = initVector[int](10)
doAssert v1[0] == 0

0 comments on commit d373d30

Please sign in to comment.