Advertisement
Guest User

main.cpp

a guest
Jul 21st, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include "provider.h"
  3.  
  4. using Graphics = int;
  5.  
  6. using GraphicsProvider = Provider<Graphics>;
  7. MACRO_DEFINE_PROVIDER_ACCESS(GraphicsProvider)
  8.  
  9. void function();
  10.  
  11. int main(int argc, char *argv[])
  12. {
  13.   {
  14.     GraphicsProvider provider;
  15.  
  16.     Graphics graphics;
  17.     provider.Register(&graphics);
  18.  
  19.     function();
  20.   }
  21.  
  22.   function();
  23.  
  24.   return 0;
  25. }
  26.  
  27. void function()
  28. {
  29.   // do something with Graphics
  30.   std::cout << Get<Graphics>() << std::endl;
  31. }
  32.  
  33. // compile and run:
  34. // g++ --std=c++14 main.cpp -o bin && ./bin
  35.  
  36. // output:
  37. // 0x7ffd9b914d9c
  38. // 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement