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

sml::aux::get_type_name<TAction>() not returning name of lambda function #597

Open
infn-ke opened this issue Sep 7, 2023 · 2 comments
Open

Comments

@infn-ke
Copy link

infn-ke commented Sep 7, 2023

When invoking the function sml::aux::get_type_name<TAction>() it does not return the name of the lambda function for the action. Instead it returns a string formatted something like action::<lambda(my_type)>. Is there really no way to get the actual name of the lambda function in state machine logger?

@Alex0vSky
Copy link

Alex0vSky commented Oct 13, 2023

I wrote this in a hurry at first:

Perhaps the simplest thing we can do is to use std::source_location::function_name in C++20.
Look at SO answer and cppreference
But SML for C++14.

But everything is simpler. To have a name, you need to use not a lambda, but a real function.
I also encountered this in the Plant UML Integration example.
Instead this

void on_s1_entry() {}
...
      , "s1"_s + sml::on_entry<_> / [] { on_s1_entry(); }

use the code next to it

void on_s1_entry_f() {}
...
struct on_s1_entry {
  auto operator()() { on_s1_entry_f(); }
} on_s1_entry;
...
      , "s1"_s + sml::on_entry<_> / on_s1_entry

to get the actual name of on_s1_entry.

The names in the example are very similar and it is easy to get confused.

@infn-ke
Copy link
Author

infn-ke commented Oct 13, 2023

I figured out the same and switched from lambdas to functors.

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

2 participants