# Static Networks `StaticNetwork` encodes the entire topology at compile time using a `make_network()` builder. Nodes and channel types are verified statically with zero runtime overhead. ## Usage ```cpp #include using namespace kpn; static int produce() { return 42; } static int double_it(int x) { return x * 2; } static void print_it(int x) { std::cout << x << '\n'; } int main() { auto src = make_node (); auto dbl = make_node(); auto prn = make_node (); auto net = make_network( edge(src, src.output<0>(), dbl, dbl.input<0>()), edge(dbl, dbl.output<0>(), prn, prn.input<0>()) ); net.set_event_handler([](std::string_view name, NodeEvent ev, auto ts) { // same API as Network }); net.start(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); net.stop(); } ``` See `examples/10_static_hello_pipeline` and `examples/11_static_fanout`. ## When to use | | `Network` | `StaticNetwork` | |---|---|---| | Topology known at | Runtime | Compile time | | Type checking | Runtime (`dynamic_cast`) | Compile time | | Overhead | Minimal | Zero | | Flexibility | Add nodes dynamically | Fixed at compile time | For most applications `Network` is sufficient. Use `StaticNetwork` when you need the absolute minimum overhead or want compile-time topology verification.