boost-ext / sml

C++14 State Machine library
https://boost-ext.github.io/sml
Boost Software License 1.0
1.14k stars 177 forks source link

Compile Error If data does not have copy constructor #166

Open mfumita opened 6 years ago

mfumita commented 6 years ago

If I compile the following code,

#include <boost/sml.hpp>

namespace sml = boost::sml;

struct data_type {
  data_type() {}
  data_type(const data_type &) = delete;
};

struct test_sm {
  test_sm() {}

  auto operator()() const {
    using namespace sml;

    return make_transition_table(
      *"start"_s = X
    );
  }

  data_type data;
};

int main() {
  using namespace sml;
  test_sm test;
  sm<test_sm> test_sm(test);
}

It gives an error of "use of deleted function" caused by the deleted copy constructor like below.

error: use of deleted function ‘test_sm::test_sm(const test_sm&)’ sm_impl(const TPool &p, aux::false_type) : sm_t{aux::try_get<sm_t>(&p)}, transitions_{(*this)()} {

This did not happen at the revision on 2017/5/30. Is this intentional change?

01e9 commented 5 years ago

I am also interested why state machine instance is copied. operator()() is executed only once, that's good.

In my project I have something similar to data example and the instance is copied many times.