Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is<TState> method only checks first orthogonal state if a single state is provided #481

Closed
guiserle opened this issue Dec 1, 2021 · 0 comments

Comments

@guiserle
Copy link
Contributor

guiserle commented Dec 1, 2021

According to user guide, is<TState> should return true when any current state matches TState, false otherwise.

However current implementation only checks the first of the orthogonal states

Expected Behavior

Following code (Based on orthogonal region example) should complete with no errors

#include <cassert>
#include <https://raw.githubusercontent.com/boost-ext/sml/master/include/boost/sml.hpp>

namespace sml = boost::sml;

namespace {
struct e1 {};
struct e2 {};
struct e3 {};

struct orthogonal_regions {
    auto operator()() const noexcept {
        using namespace sml;
        return make_transition_table(
            *"idle"_s + event<e1> = "s1"_s, "s1"_s + event<e2> = X

            ,
            *"idle2"_s + event<e2> = "s2"_s, "s2"_s + event<e3> = X);
    }
};

}  // namespace

int main() {
    sml::sm<orthogonal_regions> sm;
    using namespace sml;
    assert(sm.is("idle"_s, "idle2"_s));
    sm.process_event(e1{});
    assert(sm.is("s1"_s, "idle2"_s));
    assert(sm.is("s1"_s));      // <-- Single state check
    assert(sm.is("idle2"_s));   // <-- Single state check
    sm.process_event(e2{});
    assert(sm.is(X, "s2"_s));
    sm.process_event(e3{});
    assert(sm.is(X, X));
}

Actual Behavior

assert(sm.is("idle2"_s)); fails (assert(sm.is("s1"_s)); passes only because it is the first orthogonal state)

Steps to Reproduce the Problem

Execute above code, available on compiler explorer: https://godbolt.org/z/MzWaqoh33

Specifications

  • Version: 1.1.4
  • Platform: Any
  • Subsystem: Any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant