Proyectos
boost-ext/sml has 1,418 GitHub stars and 210 forks. GitHot measured 0 stars in 24 hours, +3 in 7 days, and 0 in 15 days. Last checked 2026-11-23 19:37 UTC. Last push 2026-11-20.
Crecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- +3
- in 15 days
- 0
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
Acerca de
Biblioteca de máquinas de estados para C++14
Herramientas de desarrolloREADME.md
OriginalSML (State Machine Language)
Your scalable C++14 one header only State Machine Library with no dependencies
Let's release a TCP connection!

Quick start
Download
[Boost::ext].SML requires only one file. Get the latest header here!
Include
#include <boost/sml.hpp>
namespace sml = boost::sml;
Dependencies
struct sender {
template<class TMsg>
constexpr void send(const TMsg& msg) { std::printf("send: %d\n", msg.id); }
};
Events
struct ack { bool valid{}; };
struct fin { int id{}; bool valid{}; };
struct release {};
struct timeout {};
Guards
constexpr auto is_valid = [](const auto& event) { return event.valid; };
Actions
constexpr auto send_fin = [](sender& s) { s.send(fin{0}); };
constexpr auto send_ack = [](const auto& event, sender& s) { s.send(event); };
State Machine
struct tcp_release {
auto operator()() const {
using namespace sml;
/**
* Initial state: *initial_state
* Transition DSL: src_state + event [ guard ] / action = dst_state
*/
return make_transition_table(
*"established"_s + event<release> / send_fin = "fin wait 1"_s,
"fin wait 1"_s + event<ack> [ is_valid ] = "fin wait 2"_s,
"fin wait 2"_s + event<fin> [ is_valid ] / send_ack = "timed wait"_s,
"timed wait"_s + event<timeout> = X
);
}
};
Usage
int main() {
using namespace sml;
sender s{};
sm<tcp_release> sm{s}; // pass dependencies via ctor
assert(sm.is("established"_s));
sm.process_event(release{}); // complexity O(1)
assert(sm.is("fin wait 1"_s));
sm.process_event(ack{true}); // prints 'send: 0'
assert(sm.is("fin wait 2"_s));
sm.process_event(fin{42, true}); // prints 'send: 42'
assert(sm.is("timed wait"_s));
sm.process_event(timeout{});
assert(sm.is(X)); // terminated
}
MSVC-2015 (Example)
- use
state<class state_name>instead of"state_name"_s - expliclty state a lambda's result type
auto action = [] -> void {}
Compile
- GCC/Clang
$CXX -std=c++14 -O2 -fno-exceptions -Wall -Wextra -Werror -pedantic tcp_release.cpp - MSVC
cl /std:c++14 /Ox /W3 tcp_release.cpp
| tcp_release.cpp | Clang-3.8 | GCC-6.3 | MSVC-2015 |
|---|---|---|---|
| Compilation Time | 0.102s | 0.118s | 0.296s |
| Binary size (stripped) | 6.2kb | 6.2kb | 105kb |
| ASM x86-64 - https://godbolt.org/z/y99L50 |
|
Run
send: 0
send: 42
Benchmark
| Enum/Switch | Variant | [Boost::ext].SML - 1.1.0 | Boost-1.65.MSM-eUML | Boost-1.65.Statechart | |
|---|---|---|---|---|---|
| Compilation time | 0.132s | 15.321s | 0.582s | 1m15.935s | 5.671s |
| Execution time | 679ms | 827ms | 622ms | 664ms | 2282ms |
| Memory usage | 1b | 2b/8b | 1b | 120b | 224b |
| Executable size | 15K | 187K | 34K | 611K | 211K |
Examples
Documentation
- Introduction
- Overview
- Features/Benchmarks
- Tutorial/Workshop
- UML vs SML
- User Guide
- Examples
- FAQ
- CHANGELOG
- [1.2.0] - 2026-06-01
- [1.1.13] - 2025-12-01
- [1.1.12] - 2025-04-02
- [1.1.11] - 2024-03-09
- [1.1.10] - 2024-03-09
- [1.1.9] - 2023-09-13
- [1.1.6] - 2022-09-07
- [1.1.5] - 2022-03-23
- [1.1.4] - 2021-02-16
- [1.1.3] - 2020-08-02
- [1.1.2] - 2020-06-14
- [1.1.1] - 2020-05-17
- [1.1.0] - 2019-01-08
- [1.0.1] - 2016-05-06
- [1.0.0] - 2016-01-28
Disclaimer [Boost::ext].SML is not an official Boost library.
Explorar proyectos relacionados
Cargando…






