diff options
| author | dyknon dyknonr5fjp | 2026-09-10 00:52:11 +0900 |
|---|---|---|
| committer | dyknon dyknonr5fjp | 2026-09-10 00:52:11 +0900 |
| commit | 92f256160f316c1d48fa12c56e6f2608b2b33811 (patch) | |
| tree | 154ca70a2a9da61f77810dd75a2aad33683aea8c /thinfunc-example.cc | |
| parent | d98e139d08d2d24426d75384f8789ccc7279bca4 (diff) | |
Diffstat (limited to 'thinfunc-example.cc')
| -rw-r--r-- | thinfunc-example.cc | 22 |
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()); |
