TLDR Web Dev · MISCELLANEOUS

GIVING C++ STD::REGEX A C MAKEOVER

nullprogram.com8 min read

Summary from the TLDR Web Dev newsletter

This article shows how to wrap the C++ `std::regex` library in a clean C interface for use in C projects. This is done by creating a custom allocator that utilizes an arena-based memory management system, preventing the need for individual object deallocation and eliminating the use of `new` and `delete` within the C++ library. By doing this, the C++ regex library can be used without directly exposing its C++ objects to the C code while still benefiting from the existing functionality of `std::regex`.