Show HN: Cppmatch – Rust-Like Pattern Matching and Error Handling for C++ I've created cppmatch, a lightweight, header-only C++ library that brings Rust-inspired pattern matching and error handling to C++. It tries to imitate the functionality of the questionmark (?) operator in C++ by using a macro that uses the gcc extension https://ift.tt/E2KnmDV This allows to create exceptionless code with non-intrusive error-as-value that unlike Exceptions, makes it clear which kinds of error a function can generate and forces you to handle (or ignore) them. The ? operator translates to *expect* To handle the errors I introduce *match* which allows to easily visit the contents of the result or any std::variant (you can use it to imitate rust enums) You can view an example of this project used in a "real way" in compiler-explorer: Simplified error types to just be a string: https://ift.tt/r9V6U7c Multiple structs as error types: https://ift.tt/d8aYSfC Feel free to give feedback or contribute to the project! https://ift.tt/5IscZbg March 16, 2025 at 10:37PM
Show HN: Cppmatch – Rust-Like Pattern Matching and Error Handling for C++ https://ift.tt/JGZakfK
Related Articles
Show HN: Free AI productivity framework for solo founders (with GPT-4) https://ift.tt/K2vIlcxShow HN: Free AI productivity framework for solo founders (with GPT-4)… Read More
Show HN: I built sales API, Stripe Atlas closed me https://ift.tt/vx7iX9jShow HN: I built sales API, Stripe Atlas closed me My Co-founder and I… Read More
Show HN: I built a create-your-own-story interactive novel that runs with GPT https://ift.tt/cMYTGwNShow HN: I built a create-your-own-story interactive novel that runs w… Read More
Show HN: Improve LLM Performance by Maximizing Iteration Speed https://ift.tt/3g6ypdvShow HN: Improve LLM Performance by Maximizing Iteration Speed LLM App… Read More
Show HN: I've built a child monitoring app with mitmproxy and WireGuard https://ift.tt/8mON3veShow HN: I've built a child monitoring app with mitmproxy and WireGuar… Read More
Show HN: Free Online Note Taker https://ift.tt/C4fYFJ6Show HN: Free Online Note Taker Hey HN community, Yesterday I develope… Read More
Show HN: What's in My Location History? https://ift.tt/25PTnDaShow HN: What's in My Location History? https://ift.tt/j7rlwGR July 1,… Read More
Show HN: Perlin noise Wang tile generator https://ift.tt/VYoyPRcShow HN: Perlin noise Wang tile generator This is a little script I wr… Read More
0 Comments: