Advertisement
Guest User

Untitled

a guest
Mar 16th, 2012
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. //test1.cpp
  2. #include <iostream>
  3. #include "test.hpp"
  4.  
  5. int main() {
  6. std::cout << foo<int>::bar.value << '\n';
  7. void f();
  8. f();
  9. std::cout << foo<int>::bar.value << '\n';
  10. }
  11.  
  12. //test2.cpp
  13. #include "test.hpp"
  14.  
  15. void f() {
  16. foo<int>::bar.value = 42;
  17. }
  18.  
  19. // test.hpp
  20. struct wrapped { int value; };
  21.  
  22. template <typename>
  23. struct foo {
  24. static wrapped bar;
  25. };
  26. template <typename T> wrapped foo<T>::bar = { 0 };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement