#include #include #include std::expected question(int n) { if (n == 42) return n; else return std::unexpected{ n < 42 ? "zu klein" : "zu groß" }; } int main() { for (int n : { 6, 7, 8, 9 }) { auto answer = question(6*n); if (answer.has_value()) // oder: if(answer) std::println("Die richtige Antwort ist {}", answer.value()); else std::println("Fehler: {}", answer.error()); } }