summaryrefslogtreecommitdiff
path: root/thinfunc-example.cc
diff options
context:
space:
mode:
Diffstat (limited to 'thinfunc-example.cc')
-rw-r--r--thinfunc-example.cc22
1 files changed, 8 insertions, 14 deletions
diff --git a/thinfunc-example.cc b/thinfunc-example.cc
index 1cf12d6..10446bf 100644
--- a/thinfunc-example.cc
+++ b/thinfunc-example.cc
@@ -33,20 +33,15 @@ using namespace tf;
struct test{
std::string name;
- test(std::string name): name(name){}
+ test(std::string name): name(name){
+ m1.bind<&test::m1, &test::message1>();
+ m2.bind<&test::m2, &test::message2>();
+ t.bind<&test::t, &test::time>();
+ }
anchor<test, void()> m1;
- func<void()>& get_m1(){
- return m1.bind<&test::m1, &test::message1>();
- }
anchor<test, void(std::string)> m2;
- func<void(std::string)>& get_m2(){
- return m2.bind<&test::m2, &test::message2>();
- }
anchor<test, std::string()> t;
- func<std::string()>& get_t(){
- return t.bind<&test::t, &test::time>();
- }
void message1(){
std::println("hello! I'm {}.", name);
@@ -74,10 +69,9 @@ struct test{
int main(){
test o("a test object");
- func<void()>& m1 = o.get_m1();
- func<void(std::string)>& m2 = o.get_m2();
- o.get_t();
- func<std::string()>& t = o.t.assume_bound<&test::t, &test::time>();
+ func<void()>& m1 = o.m1.bound();
+ func<void(std::string)>& m2 = o.m2.bound();
+ func<std::string()>& t = o.t.bound<&test::t, &test::time>();
m1();
m2(t());