Skip to content

Commit 8a99cb9

Browse files
authored
Merge pull request #19 from Clonkk/destroy_bug_15
Destroy bug 15
2 parents ad46fa5 + c3ba630 commit 8a99cb9

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

cppstl/std_complex.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ func conj*[T: SomeFloat](self: CppComplex[T]): CppComplex[T] {.importcpp: "std::
3131
{.pop.}
3232
3333
import complex
34-
proc toComplex*[T](c: CppComplex[T]) : Complex[T] =
34+
proc toComplex*[T](c: CppComplex[T]): Complex[T] =
3535
result.re = c.real()
3636
result.im = c.imag()
3737
38-
proc toCppComplex*[T](c: Complex[T]) : CppComplex[T] =
38+
proc toCppComplex*[T](c: Complex[T]): CppComplex[T] =
3939
result = initCppComplex(c.re, c.im)
4040
4141
proc `$`*[T](c: CppComplex[T]): string =

cppstl/std_string.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ proc last*(v: CppString): cchar {.inline.} =
287287
v.back()
288288

289289
# Nim Iterators
290-
iterator items*(v: CppString): cchar=
290+
iterator items*(v: CppString): cchar =
291291
## Iterate over all the elements in CppString `v`.
292292
for idx in 0.csize_t ..< v.len():
293293
yield v[idx]
@@ -297,7 +297,7 @@ iterator pairs*(v: CppString): (csize_t, cchar) =
297297
for idx in 0.csize_t ..< v.len():
298298
yield (idx, v[idx])
299299

300-
iterator mitems*(v: var CppString): var cchar=
300+
iterator mitems*(v: var CppString): var cchar =
301301
## Iterate over all the elements in CppString `v`.
302302
for idx in 0.csize_t ..< v.len():
303303
yield v[idx]

cppstl/std_vector.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ proc last*[T](v: CppVector[T]): T {.inline.} =
483483
484484
# Nim Iterators
485485
486-
iterator items*[T](v: CppVector[T]): T=
486+
iterator items*[T](v: CppVector[T]): T =
487487
## Iterate over all the elements in CppVector `v`.
488488
runnableExamples:
489489
var

tests/destroy_bug_15.nim

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import cppstl/std_vector
2+
3+
type Foo = object
4+
x: int
5+
6+
proc `=destroy`*(a: var Foo) {.inline.} =
7+
echo ("in destroy", a.x)
8+
9+
proc main =
10+
var v = initCppVector[Foo]()
11+
12+
v.add Foo(x: 10)
13+
v.add Foo(x: 11)
14+
v.add Foo(x: 12)
15+
16+
echo "ok0"
17+
echo v
18+
19+
echo "ok1"
20+
echo v
21+
22+
echo "ok2"
23+
24+
# Clear should call object destructor
25+
v.clear()
26+
echo "ok3"
27+
28+
main()

0 commit comments

Comments
 (0)