A nice C++20 pattern matching library

Not strictly JUCE but you can finally enjoypatum, an extremely compact, wonderfully nice to use, excessively extensible, tremendously fast pattern matching library using C++20 with no macros! Took some time of manual labour and brain twisting (not counting the additional grey hairs!) to iron out most of the edge cases, but it’s here:

Until we wait for C++26/29, this is one of the most ergonomic implementation of pattern matching for C++ out there, and it even beats if else and switch in generated binary instructions and performance !

2 Likes

Cool! What compiler did you use to produce the assembler? Have you tested how it behaves with MSVC? MSVC has a funny habit of exposing the method name when a lambda is declared inside ( Hunting for readable strings in the binary (anti-piracy saga) ) so it is a potential reverse engineering give-away if the compiler had the occurrence of declaring it.

Assembler in the readme is clang (don’t recall the version but pretty recent). Not sure about msvc, i always considered it a crappy compiler same as its OS it runs on. I just support it because people still asks for it, but if it was for me, i would have scrapped support for it already.