Files
Nim/tests/cpp/tempty_generic_obj.nim
metagn e2ef322754 update CI to macos 13 (#24157)
Followup to #24154, packages aren't ready for macos 14 (M1/ARM CPU) yet
and it seems to be preview on azure, so upgrade to macos 13 for now.

Macos 12 gives a warning:

```
You are using macOS 12.
We (and Apple) do not provide support for this old version.
It is expected behaviour that some formulae will fail to build in this old version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from Homebrew or its maintainers on social media.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.
```

(cherry picked from commit 4a63186cda)
2024-10-09 07:48:30 +02:00

47 lines
1.1 KiB
Nim

discard """
targets: "cpp"
output: '''
int
float'''
"""
import typetraits
# bug #4625
type
Vector[T] {.importcpp: "std::vector<'0 >", header: "vector".} = object
proc initVector[T](): Vector[T] {.importcpp: "'0(@)", header: "vector", constructor.}
proc doSomething[T](v: var Vector[T]) =
echo T.name
var v = initVector[int]()
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*[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] =
mkVector[cint]()
proc bar(): VectorAlt[cstring] =
mkVector[cstring]()
var x = foo()
var y = bar()
proc init[T; Self: Vector[T]](_: typedesc[Self], n: csize_t): Vector[T]
{.importcpp: "std::vector<'*0>(@)", header: "<vector>", constructor, nodecl.}
proc size[T](x: Vector[T]): csize_t
{.importcpp: "#.size()", header: "<vector>", nodecl.}
var z = Vector[int16].init(32)
assert z.size == 32