From 92f256160f316c1d48fa12c56e6f2608b2b33811 Mon Sep 17 00:00:00 2001 From: dyknon Date: Thu, 10 Sep 2026 00:52:11 +0900 Subject: better syntax, more protection, std::function compatibility --- thinfunc-example.cc | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'thinfunc-example.cc') 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 m1; - func& get_m1(){ - return m1.bind<&test::m1, &test::message1>(); - } anchor m2; - func& get_m2(){ - return m2.bind<&test::m2, &test::message2>(); - } anchor t; - func& 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& m1 = o.get_m1(); - func& m2 = o.get_m2(); - o.get_t(); - func& t = o.t.assume_bound<&test::t, &test::time>(); + func& m1 = o.m1.bound(); + func& m2 = o.m2.bound(); + func& t = o.t.bound<&test::t, &test::time>(); m1(); m2(t()); -- cgit v1.2.3