Sunday, March 16, 2025
Show HN: Cppmatch – Rust-Like Pattern Matching and Error Handling for C++ https://ift.tt/wTGpIuA
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/SZyDOYh 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/GSE145O Multiple structs as error types: https://ift.tt/pQJnAYR Feel free to give feedback or contribute to the project! https://ift.tt/HuEP0Jq March 16, 2025 at 10:37PM
Subscribe to:
Post Comments (Atom)
Show HN: Gemini Document Processor – Generate Th Summaries from PDF/ePub with AI https://ift.tt/ZvMI6cS
Show HN: Gemini Document Processor – Generate Th Summaries from PDF/ePub with AI Hello HN! I'd like to share Gemini Document Processor, ...
-
Show HN: High school robotics code/CAD/design binder release Hello HN! My name is Patrick, and I am a junior at my High School’s FRC robotic...
-
Show HN: D&D meets Siri – Interactive voice adventure Hey HN! I've been building tooling for voice-driven apps over the past few mon...
-
Show HN: I Made an AI Social Media Manager to Automate Content Creation Hey HN, I am a Solopreneur, and I love building apps to automate bor...
No comments:
Post a Comment