Make regex::assign not clobber the regex in case of failure. Fixes PR#22213

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@225799 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/regex b/include/regex
index 690213a..39e106c 100644
--- a/include/regex
+++ b/include/regex
@@ -2599,9 +2599,7 @@
         assign(_ForwardIterator __first, _ForwardIterator __last,
                             flag_type __f = regex_constants::ECMAScript)
         {
-            __member_init(__f);
-            __parse(__first, __last);
-            return *this;
+            return assign(basic_regex(__first, __last, __f));
         }
 
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS