[cfe-dev] Why does clang-tidy recommend deleted member functions should be public?

Nicolas Lesser via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 30 23:34:49 PDT 2017

There's nothing inherently wrong with deleting member functions that are
private, but if they are public, you will get a better error message
(namely that the function is deleted) instead of an error message that says
that the functions are private.

AFAIK, Qt supports C++11, but also previous versions. I don't know how they
implemented Q_DISABLE_COPY, but it probably expands to copy constructor and
copy assignment declarations before C++11, and if you enable C++11 mode,
deletes them instead. In pre-C++11, the declarations would have to be
private, so you get an error at compile time and not at link time.

If you're only compiling with C++11, it should be safe to put the macro in
public. Alternately, you can always delete the copy constructor and
assignment yourself.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171031/441c810a/attachment.html>

More information about the cfe-dev mailing list