summary refs log tree commit diff stats
path: root/tests/cpp/tget_subsystem.nim
blob: e9a3fabdd2766d990d9485cdd9328f4d03738f1d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
discard """
  targets: "cpp"
"""

{.emit: """

namespace System {
  struct Input {};
}

struct SystemManager {
  template <class T>
  static T* getSubsystem() { return new T; }
};

""".}

type Input {.importcpp: "System::Input".} = object
proc getSubsystem*[T](): ptr T {.
  importcpp: "SystemManager::getSubsystem<'*0>()", nodecl.}

let input: ptr Input = getSubsystem[Input]()


# bug #4910

proc foo() =
  var ts: array[10, int]
  for t in mitems(ts):
     t = 123
. run/0: instruction main/0 run/0: ingredient 0 is 23 mem/0: storing 23 in location 1