tdont_init_instantiation.nim 448 B

123456789101112131415161718192021222324252627282930
  1. discard """
  2. targets: "cpp"
  3. output: ''''''
  4. disabled: true
  5. """
  6. # bug #5140
  7. {.emit:"""
  8. #import <cassert>
  9. template <typename X> class C {
  10. public:
  11. int d;
  12. C(): d(1) { }
  13. C<X>& operator=(const C<X> other) {
  14. assert(d == 1);
  15. }
  16. };
  17. """.}
  18. type C[X] {.importcpp, header: "<stdio.h>", nodecl.} = object
  19. proc mkC[X]: C[X] {.importcpp: "C<'*0>()", constructor, nodecl.}
  20. proc foo(): C[int] =
  21. result = mkC[int]()
  22. let gl = foo()