Skip to content

basic_regex is missing move operations #270

Description

@eisenwave

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:

  1. 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.

  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions