#include #include #include main: () -> int = { std::set_terminate(std::abort); x: std::string; // note: uninitialized! if flip_a_coin() { x = "xyzzy"; } else { fill( out x, "plugh", 40 ); // note: constructs x! } print_decorated(x); } fill: ( out x: std::string, value: std::string, count: int ) pre( value.ssize() >= count, "fill: value must contain at least count elements" ) = { x = value.substr(0, count); } print_decorated: (x:_) = std::cout << ">> [" << x << "]\n"; // for test determinism, force "fill" branch bool flip_a_coin() { // Change std::mt19937 to std::random_device for non-deterministic PRNG static std::mt19937 rand; return rand() % 2 == 1; }