Topic: N2369 library problem: basic_regex should be moveable


Author: =?iso-8859-1?q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Wed, 29 Aug 2007 16:30:47 CST
Raw View
According to the current state of the standard draft, the class
template basic_regex, as described in 28.8-[re.regex]/3, is
neither MoveConstructible, MoveAssignable, nor Swappable.
IMO it should be, because typical regex state machines tend
to have a rather large data quantum and I have seen several
use cases, where a factory function returns regex values,
which would take advantage of moveabilities.

Proposed Resolution:

(a) In the header <regex> synopsis [re.syn], just below the function
template swap add two further overloads:

template <class charT, class traits>
void swap(basic_regex<charT, traits>&& e1, basic_regex<charT, traits>&
e2);
template <class charT, class traits>
void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>&&
e2);

In the class definition of basic_regex, just below [re.regex]/3,
perform the following changes:

(b) Just after the copy c'tor:
basic_regex(basic_regex&&);

(c) Just after the copy-assignment op.:
basic_regex& operator=(basic_regex&&);

(d) Just after the first assign overload insert:
basic_regex& assign(basic_regex&& that);

(e) Change the current swap function to read:
void swap(basic_regex&&);

(f) In [re.regex.construct], just below the copy c'tor add a
corresponding member definition of:
basic_regex(basic_regex&&);

(g) Also in [re.regex.construct], just below the copy assignment
c'tor add a corresponding member definition of:
basic_regex& operator=(basic_regex&&);

(h) In [re.regex.assign], just below the first assign overload add
a corresponding member definition of:
basic_regex& assign(basic_regex&& that);

(i) In [re.regex.swap], change the signature of swap to
say:
void swap(basic_regex&& e);

(j) In [re.regex.nmswap], just below the single binary swap
function, add the two missing overloads:
template <class charT, class traits>
void swap(basic_regex<charT, traits>&& e1, basic_regex<charT, traits>&
e2);
template <class charT, class traits>
void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>&&
e2);

Of course there would be need of corresponding proper standardese
to describe these additions.

Greetings from Bremen,

Daniel Kr   gler


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]