Created
October 7, 2014 18:16
-
-
Save Fiona-J-W/8fdd5219d34f63a8d508 to your computer and use it in GitHub Desktop.
Policy-Types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <string> | |
#include <vector> | |
#include <yoga/yoga.hpp> | |
template<typename Functions> | |
class basic_raii { | |
public: | |
basic_raii() { | |
Functions::create(); | |
} | |
~basic_raii() { | |
Functions::release(); | |
} | |
int otherfun(int i) { | |
return Functions::fun(i); | |
} | |
}; | |
void my_create() { | |
yoga::writeln("my_create"); | |
} | |
void my_release() { | |
yoga::writeln("my_release"); | |
} | |
int my_fun(int i) { | |
yoga::writefln("my_fun(%s)", i); | |
return i * 2; | |
} | |
struct my_stuff{ | |
static decltype(auto) create(){return my_create();} | |
static decltype(auto) release(){return my_create();} | |
static decltype(auto) fun(int i){return my_fun(i);} | |
}; | |
using my_foo = basic_raii<my_stuff>; | |
int main() { | |
my_foo foo; | |
foo.otherfun(3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment