gcc/clang "use of deleted function" in CI
The function is marked = delete, or the compiler implicitly deleted it because a member or base cannot be copied, moved, or default-constructed. The call is forbidden.
What this error means
Copying, moving, or default-constructing a type fails with "use of deleted function", often for a class holding a std::unique_ptr or a std::mutex.
clang
app.cpp:9:14: error: use of deleted function 'Worker::Worker(const Worker&)'
note: 'Worker::Worker(const Worker&)' is implicitly deleted because the default
note: definition would copy 'std::unique_ptr<Impl>' which is non-copyableCommon causes
How to fix it
Move instead of copy, or define the operation
- Use std::move for move-only types instead of copying them.
- If copying is intended, give the class a meaningful copy constructor/assignment.
clang
Worker b = std::move(a); // move-only: transfer, do not copyHow to prevent it
- Treat types holding unique_ptr/mutex as move-only, and explicitly default or define the special members you intend to support.
Related guides
gcc/clang "passing const X as this discards qualifiers" in CIFix gcc/clang "passing 'const X' as 'this' argument discards qualifiers" in CI - a non-const member function…
gcc/clang "cannot bind non-const lvalue reference to an rvalue" in CIFix gcc/clang "cannot bind non-const lvalue reference of type X& to an rvalue" in CI - a temporary is passed…