diff --git a/src/regex.cc b/src/regex.cc index df5af661..b62bdddf 100644 --- a/src/regex.cc +++ b/src/regex.cc @@ -6,10 +6,10 @@ namespace Kakoune { Regex::Regex(StringView re, RegexCompileFlags flags) - : m_impl{new CompiledRegex{}}, + : m_impl{new Impl{}}, m_str{re.str()} { - *m_impl = compile_regex(re, flags); + static_cast(*m_impl) = compile_regex(re, flags); } int Regex::named_capture_index(StringView name) const diff --git a/src/regex.hh b/src/regex.hh index c0f3970e..c65ba60c 100644 --- a/src/regex.hh +++ b/src/regex.hh @@ -3,6 +3,7 @@ #include "string.hh" #include "regex_impl.hh" +#include "ref_ptr.hh" namespace Kakoune { @@ -27,7 +28,9 @@ public: const CompiledRegex* impl() const { return m_impl.get(); } private: - RefPtr m_impl; + struct Impl : RefCountable, CompiledRegex {}; + + RefPtr m_impl; String m_str; }; diff --git a/src/regex_impl.hh b/src/regex_impl.hh index 8f11f1af..d8df2255 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -3,7 +3,6 @@ #include "exception.hh" #include "flags.hh" -#include "ref_ptr.hh" #include "unicode.hh" #include "utf8.hh" #include "vector.hh" @@ -66,7 +65,7 @@ struct CharacterClass }; -struct CompiledRegex : RefCountable, UseMemoryDomain +struct CompiledRegex : UseMemoryDomain { enum Op : char {