|
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::move to a type, but no move is actually happening. If the user decides not to std::move, they forever pessimize and do not opt into a move constructor added by Boost in the future.
-
Internally, basic_regex is wrapping a std::shared_ptr to some implementation. std::shared_ptr significantly 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 to std::move a std::shared_ptr when it's possible, even if copying remains a shallow copy.
regex/include/boost/regex/v5/basic_regex.hpp
Lines 370 to 377 in ed6ebbd
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.