Merge pull request #2699 from SSPkrolik/newrefref
new now able to make distinction between ref and non-ref types, so we…
This commit is contained in:
commit
6fea1a7bb6
1 changed files with 8 additions and 2 deletions
|
|
@ -176,10 +176,16 @@ proc new*[T](a: var ref T) {.magic: "New", noSideEffect.}
|
||||||
## creates a new object of type ``T`` and returns a safe (traced)
|
## creates a new object of type ``T`` and returns a safe (traced)
|
||||||
## reference to it in ``a``.
|
## reference to it in ``a``.
|
||||||
|
|
||||||
proc new*(T: typedesc): ref T =
|
proc new*(T: typedesc): auto =
|
||||||
## creates a new object of type ``T`` and returns a safe (traced)
|
## creates a new object of type ``T`` and returns a safe (traced)
|
||||||
## reference to it as result value
|
## reference to it as result value
|
||||||
new(result)
|
when (T is ref):
|
||||||
|
var r: T
|
||||||
|
else:
|
||||||
|
var r: ref T
|
||||||
|
new(r)
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
proc internalNew*[T](a: var ref T) {.magic: "New", noSideEffect.}
|
proc internalNew*[T](a: var ref T) {.magic: "New", noSideEffect.}
|
||||||
## leaked implementation detail. Do not use.
|
## leaked implementation detail. Do not use.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue