Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "provider.h"
- using Graphics = int;
- using GraphicsProvider = Provider<Graphics>;
- MACRO_DEFINE_PROVIDER_ACCESS(GraphicsProvider)
- void function();
- int main(int argc, char *argv[])
- {
- {
- GraphicsProvider provider;
- Graphics graphics;
- provider.Register(&graphics);
- function();
- }
- function();
- return 0;
- }
- void function()
- {
- // do something with Graphics
- std::cout << Get<Graphics>() << std::endl;
- }
- // compile and run:
- // g++ --std=c++14 main.cpp -o bin && ./bin
- // output:
- // 0x7ffd9b914d9c
- // 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement