boostorg / msm

Boost.org msm module
http://boost.org/libs/msm
31 stars 53 forks source link

Added rvalue references support to back::state_machine. #8

Closed redboltz closed 6 years ago

redboltz commented 8 years ago

I'd like to use a class that inherits state_machine_def and contains move only type member variables as follows:

#include <boost/msm/back/state_machine.hpp>
#include <boost/msm/front/state_machine_def.hpp>

namespace msm = boost::msm;

struct foo {
    foo() = default;
    foo(foo const&) = delete;
    foo(foo&&) = default;
};

// ----- State machine

struct Sm1_:msm::front::state_machine_def<Sm1_> {
    struct State1:msm::front::state<> {};
    typedef State1 initial_state;
    Sm1_(foo&& val):val(std::move(val)) {}
    foo val;
};

typedef msm::back::state_machine<Sm1_> Sm1;

int main() {
    foo f;
    Sm1 sm1(std::move(f));
}

However, msm::back::state_machine cannot forward the arguments correctly. So I wrote the pull request that solves this issue.

redboltz commented 6 years ago

Thank you!!

henry-ch commented 6 years ago

You did all the work. I only reviewed. Sorry for the very long delay!