mtlsemulation.h 628 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <stdio.h>
  2. struct Foo1 {
  3. /*
  4. uncommenting would give:
  5. error: initializer for thread-local variable must be a constant expression
  6. N_LIB_PRIVATE NIM_THREADVAR Foo1 g1__9brEZhPEldbVrNpdRGmWESA;
  7. */
  8. // Foo1() noexcept { }
  9. /*
  10. uncommenting would give:
  11. error: type of thread-local variable has non-trivial destruction
  12. */
  13. // ~Foo1() { }
  14. int x;
  15. };
  16. struct Foo2 {
  17. Foo2() noexcept { }
  18. ~Foo2() { }
  19. int x;
  20. };
  21. static int ctorCalls = 0;
  22. static int dtorCalls = 0;
  23. struct Foo3 {
  24. Foo3() noexcept {
  25. ctorCalls = ctorCalls + 1;
  26. x = 10;
  27. }
  28. ~Foo3() {
  29. dtorCalls = dtorCalls + 1;
  30. }
  31. int x;
  32. };