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: Gridtalk - Leave comments anywhere on Earth (Flask + MapTiler) https://ift.tt/4U7DF0rShow HN: Gridtalk - Leave comments anywhere on Earth (Flask + MapTiler… Read More
Show HN: I built a tool to stop chasing users for feedback and screenshots https://ift.tt/jU7v61CShow HN: I built a tool to stop chasing users for feedback and screens… Read More
Show HN: Hoodmaps Meets 4chan https://ift.tt/dsTegwoShow HN: Hoodmaps Meets 4chan I made this as a pair programming exerci… Read More
Show HN: I built a tool that helps with user onboarding and app understanding https://ift.tt/eNdtVj5Show HN: I built a tool that helps with user onboarding and app unders… Read More
Show HN: PDF to MD by LLMs – Extract Text/Tables/Image Descriptives by GPT4o https://ift.tt/NrGJBzdShow HN: PDF to MD by LLMs – Extract Text/Tables/Image Descriptives by… Read More
Show HN: Inbound Email (SMTP) to Webhook https://ift.tt/dl3ImrWShow HN: Inbound Email (SMTP) to Webhook Here's my first (hopefully of… Read More
Show HN: Formulaer – Free, simple and clean forms https://ift.tt/AihXfRWShow HN: Formulaer – Free, simple and clean forms https://formulaer.co… Read More
Show HN: I Wrote a Book on Java https://ift.tt/Q1CZHwBShow HN: I Wrote a Book on Java https://ift.tt/dWO6vmt... This book is… Read More
0 Comments: