aboutsummaryrefslogtreecommitdiff
path: root/cutl/re
diff options
context:
space:
mode:
Diffstat (limited to 'cutl/re')
-rw-r--r--cutl/re/re.cxx44
1 files changed, 14 insertions, 30 deletions
diff --git a/cutl/re/re.cxx b/cutl/re/re.cxx
index f2a6a67..c996f4e 100644
--- a/cutl/re/re.cxx
+++ b/cutl/re/re.cxx
@@ -67,14 +67,14 @@ namespace cutl
template <>
basic_regex<char>::
basic_regex (basic_regex const& r)
- : impl_ (new impl (r.impl_->r))
+ : str_ (r.str_), impl_ (new impl (r.impl_->r))
{
}
template <>
basic_regex<wchar_t>::
basic_regex (basic_regex const& r)
- : impl_ (new impl (r.impl_->r))
+ : str_ (r.str_), impl_ (new impl (r.impl_->r))
{
}
@@ -82,7 +82,9 @@ namespace cutl
basic_regex<char>& basic_regex<char>::
operator= (basic_regex const& r)
{
+ string_type tmp (r.str_);
impl_->r = r.impl_->r;
+ str_.swap (tmp);
return *this;
}
@@ -90,7 +92,9 @@ namespace cutl
basic_regex<wchar_t>& basic_regex<wchar_t>::
operator= (basic_regex const& r)
{
+ string_type tmp (r.str_);
impl_->r = r.impl_->r;
+ str_.swap (tmp);
return *this;
}
@@ -98,6 +102,8 @@ namespace cutl
void basic_regex<char>::
init (string_type const* s, bool icase)
{
+ string_type tmp (s == 0 ? string_type () : *s);
+
try
{
if (impl_ == 0)
@@ -111,12 +117,16 @@ namespace cutl
{
throw basic_format<char> (s == 0 ? "" : *s, e.what ());
}
+
+ str_.swap (tmp);
}
template <>
void basic_regex<wchar_t>::
init (string_type const* s, bool icase)
{
+ string_type tmp (s == 0 ? string_type () : *s);
+
try
{
if (impl_ == 0)
@@ -130,6 +140,8 @@ namespace cutl
{
throw basic_format<wchar_t> (s == 0 ? L"" : *s, e.what ());
}
+
+ str_.swap (tmp);
}
template <>
@@ -189,33 +201,5 @@ namespace cutl
return tr1::regex_replace (s, impl_->r, sub, f);
}
-
- template <>
- string basic_regex<char>::
- str () const
- {
- return impl_->r.str ();
- }
-
- template <>
- wstring basic_regex<wchar_t>::
- str () const
- {
- return impl_->r.str ();
- }
-
- template <>
- bool basic_regex<char>::
- empty () const
- {
- return impl_->r.empty ();
- }
-
- template <>
- bool basic_regex<wchar_t>::
- empty () const
- {
- return impl_->r.empty ();
- }
}
}