diff --git a/src/rime/gear/key_binder.cc b/src/rime/gear/key_binder.cc index 0d8e2f1a67..de37366954 100644 --- a/src/rime/gear/key_binder.cc +++ b/src/rime/gear/key_binder.cc @@ -16,8 +16,6 @@ #include #include -using namespace std::placeholders; - namespace rime { enum KeyBindingCondition { @@ -197,13 +195,21 @@ void KeyBindings::LoadBindings(const an& bindings) { continue; } } else if (auto option = map->GetValue("toggle")) { - binding.action = std::bind(&toggle_option, _1, option->str()); + binding.action = [option](auto engine) { + toggle_option(engine, option->str()); + }; } else if (auto option = map->GetValue("set_option")) { - binding.action = std::bind(&set_option, _1, option->str()); + binding.action = [option](auto engine) { + set_option(engine, option->str()); + }; } else if (auto option = map->GetValue("unset_option")) { - binding.action = std::bind(&unset_option, _1, option->str()); + binding.action = [option](auto engine) { + unset_option(engine, option->str()); + }; } else if (auto schema = map->GetValue("select")) { - binding.action = std::bind(&select_schema, _1, schema->str()); + binding.action = [schema](auto engine) { + select_schema(engine, schema->str()); + }; } else { LOG(WARNING) << "invalid key binding #" << i << "."; continue; diff --git a/src/rime/lever/deployment_tasks.cc b/src/rime/lever/deployment_tasks.cc index 05336f27c4..d4a75aaf26 100644 --- a/src/rime/lever/deployment_tasks.cc +++ b/src/rime/lever/deployment_tasks.cc @@ -29,8 +29,6 @@ #include #endif -using namespace std::placeholders; - namespace fs = std::filesystem; namespace rime { diff --git a/src/rime/service.cc b/src/rime/service.cc index 616c8765a7..e40493ae92 100644 --- a/src/rime/service.cc +++ b/src/rime/service.cc @@ -16,10 +16,11 @@ namespace rime { Session::Session() { engine_.reset(Engine::Create()); - engine_->sink().connect(std::bind(&Session::OnCommit, this, _1)); + engine_->sink().connect([this](auto text) { OnCommit(text); }); SessionId session_id = reinterpret_cast(this); - engine_->message_sink().connect( - std::bind(&Service::Notify, &Service::instance(), session_id, _1, _2)); + engine_->message_sink().connect([session_id](auto type, auto value) { + Service::instance().Notify(session_id, type, value); + }); } bool Session::ProcessKey(const KeyEvent& key_event) { @@ -65,7 +66,7 @@ Schema* Session::schema() const { Service::Service() { deployer_.message_sink().connect( - std::bind(&Service::Notify, this, 0, _1, _2)); + [this](auto type, auto value) { Notify(0, type, value); }); } Service::~Service() { diff --git a/src/rime_api_impl.h b/src/rime_api_impl.h index 64aa605293..7749ce98bc 100644 --- a/src/rime_api_impl.h +++ b/src/rime_api_impl.h @@ -38,10 +38,11 @@ RIME_DEPRECATED void RimeSetup(RimeTraits* traits) { RIME_DEPRECATED void RimeSetNotificationHandler(RimeNotificationHandler handler, void* context_object) { - using namespace std::placeholders; if (handler) { Service::instance().SetNotificationHandler( - std::bind(handler, context_object, _1, _2, _3)); + [context_object, handler](auto id, auto type, auto value) { + handler(context_object, id, type, value); + }); } else { Service::instance().ClearNotificationHandler(); }