-
Notifications
You must be signed in to change notification settings - Fork 104
Description
regex/include/boost/regex/v5/basic_regex.hpp
Lines 370 to 377 in ed6ebbd
| basic_regex& operator=(const basic_regex& that) | |
| { | |
| return assign(that); | |
| } | |
| basic_regex& operator=(const charT* ptr) | |
| { | |
| return assign(ptr); | |
| } |
Notice that while there is a copy constructor and copy assignment operator, there are no move operations. This is bad for two reasons:
-
Clangd may give the user a warning when they apply
std::moveto a type, but no move is actually happening. If the user decides not tostd::move, they forever pessimize and do not opt into a move constructor added by Boost in the future. -
Internally,
basic_regexis wrapping astd::shared_ptrto some implementation.std::shared_ptrsignificantly benefits from move operations because it allows for stealing the pointer within another smart pointer; the reference counter is never updated. It is somewhat wasteful not tostd::moveastd::shared_ptrwhen it's possible, even if copying remains a shallow copy.