move std function
This commit is contained in:
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
//! \~english Sets a callback invoked when the machine finishes.
|
||||
//! \~russian Задает callback-функцию, вызываемую при завершении машины.
|
||||
void setOnFinish(std::function<void()> f) { on_finish = f; }
|
||||
void setOnFinish(std::function<void()> f) { on_finish = std::move(f); }
|
||||
|
||||
|
||||
//! \~english Posts an event to active states and triggers the first matching transition.
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
template<typename Ret, typename... Args>
|
||||
FunctionBase * makeFunction(std::function<Ret(Args...)> func) {
|
||||
auto * ret = new Function<Args...>();
|
||||
ret->func = func;
|
||||
ret->func = std::move(func);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
//! \~russian Объявляет состояния, используемые в PIStateMachine
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
State machine node
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
State machine node
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -196,10 +196,10 @@ class PIP_EXPORT PIStateLambda: public PIStateBase {
|
||||
public:
|
||||
//! \~english Creates a state backed by enter and exit callbacks.
|
||||
//! \~russian Создает состояние с callback-функциями входа и выхода.
|
||||
PIStateLambda(std::function<void()> on_enter, std::function<void()> on_exit = nullptr, const PIString & n = {}): PIStateBase(n) {
|
||||
enter = on_enter;
|
||||
exit = on_exit;
|
||||
}
|
||||
PIStateLambda(std::function<void()> on_enter, std::function<void()> on_exit = nullptr, const PIString & n = {})
|
||||
: PIStateBase(n)
|
||||
, enter(std::move(on_enter))
|
||||
, exit(std::move(on_exit)) {}
|
||||
|
||||
|
||||
//! \~english Executes the enter callback.
|
||||
@@ -228,9 +228,8 @@ class PIP_EXPORT PIStateFinal: public PIStateBase {
|
||||
public:
|
||||
//! \~english Creates a final state with an optional callback executed on entry.
|
||||
//! \~russian Создает финальное состояние с необязательной callback-функцией, выполняемой при входе.
|
||||
PIStateFinal(std::function<void()> on_finish = nullptr, const PIString & n = {}): PIStateBase(n) {
|
||||
PIStateFinal(std::function<void()> on_finish = nullptr, const PIString & n = {}): PIStateBase(n), enter(std::move(on_finish)) {
|
||||
is_final = true;
|
||||
enter = on_finish;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ PITransitionBase::~PITransitionBase() {
|
||||
|
||||
|
||||
PITransitionBase * PITransitionBase::addAction(std::function<void()> a) {
|
||||
action = a;
|
||||
action = std::move(a);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user