Checkpoint: Describe a variant
Challenge on lesson: Checkpoint: One Function, Three Types
CHALLENGE
Difficulty: intermediate+25 XP
Implement std::string describe(const std::variant<int, double, std::string>& v) returning exactly "int: 42", "double: 3.50" (always two decimals), or "string: hi" depending on the held alternative. Use std::visit with a generic lambda and if constexpr โ no manual index() branching.
Press Submit to check your solution.
Back to lesson: Checkpoint: One Function, Three Types