8000 Add compile-time regex support using Hanickadot's CTRE · Issue #37 · getml/reflect-cpp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Add compile-time regex support using Hanickadot's CTRE #37
Closed
@ChemiCalChems

Description

@ChemiCalChems

It would be nice to add support for compile-time regular expressions for the following reasons as it would

  • Allow for compile-time checking of validation regexes (pretty much impossible to push invalid regexes if the code doesn't compile)
  • Quicker runtime validation of fields (since the regex is processed at compile-time)
  • Allow for compile-time validation whenever we (eventually) support compile-time parsing of JSON

This last point seems like science-fiction, or like something that wouldn't ever be useful, but with the addition of #embed to C23 and its likely addition to C++ at some point (hopefully by C++26) it wouldn't be crazy to expect users to want to configure programs using inline / embedded JSON or other formats. There are already a few options for compile-time JSON parsing, so it's not unheard of, in which case, validation of JSON fields would be necessary too.

For all this, I propose (and will be working on a PR for) the addition of Hanickadot's CTRE as a dependency, as well as tweaks in the validator code to get rid of the extremely slow std::regex. If you want to see the speed differences, please check P1433R0, which received a very positive reaction from the C++ Standard's committee (hopefully we'll have a constexpr capable option for regex in the standard library soon).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0