Files
Nim/tests/cpp/temitlist.nim
metagn 4a63186cda 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.
```
2024-10-06 06:33:44 +02:00

38 lines
863 B
Nim

discard """
targets: "cpp"
output: '''
6.0
0'''
"""
# bug #4730
type Vector*[T] {.importcpp: "std::vector", header: "<vector>".} = object
template `[]=`*[T](v: var Vector[T], key: int, val: T) =
{.emit: [v, "[", key, "] = ", val, ";"].}
proc setLen*[T](v: var Vector[T]; size: int) {.importcpp: "resize", nodecl.}
proc `[]`*[T](v: var Vector[T], key: int): T {.importcpp: "(#[#])", nodecl.}
proc main =
var v: Vector[float]
v.setLen 1
v[0] = 6.0
echo v[0]
main()
#------------
#bug #6837
type StdString {.importCpp: "std::string", header: "<string>", byref.} = object
proc initString(): StdString {.constructor, importCpp: "std::string(@)", header: "<string>".}
proc size(this: var StdString): csize_t {.importCpp: "size", header: "<string>".}
proc f(): csize_t =
var myString: StdString = initString()
return myString.size()
echo f()