#pragma once #include #include #include namespace jvalidate::detail { class RegexEngine { public: virtual ~RegexEngine() = default; virtual bool operator()(std::string const & regex, std::string const & text) = 0; }; class StdRegexEngine final : public RegexEngine { private: std::unordered_map cache_; public: bool operator()(std::string const & regex, std::string const & text) { return std::regex_match(text, cache_.try_emplace(regex, regex).first->second); } }; }