0

I'm very newbie in C++. I got the code about the finite state machine on github. There are things in the code I don't understand. For example, I don't know why the use using in the struct ,and what is purpose of the line typename _state_instance<S>::value_type _state_instance<S>::value

  struct _state_instance
  {
    using value_type = S;
    using type = _state_instance<S>;
    static S value;
  };

  template<typename S>
  typename _state_instance<S>::value_type _state_instance<S>::value;

Thanks a lot!

  • 3
    Refer to a [good C++ book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). The basics can be found in the books mentioned in the above list. – Jason May 30 '22 at 10:04
  • 1
    BTW this small part of code is a code smell. Looks like some stupid attempt to for singleton template. What is the source of this code? I would not trust its author. – Marek R May 30 '22 at 10:15
  • @MarekR This seems like [tinyfsm](https://github.com/digint/tinyfsm/blob/master/include/tinyfsm.hpp). – heap underrun May 30 '22 at 10:50

0 Answers0