diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-02-27 18:34:16 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-02-27 18:34:16 +0000 |
commit | 50a130cff5af183cd8620ae69f5456f88f228bb6 (patch) | |
tree | 895d3ee549c53d2f1be4d6f6562b44b055270594 /docs/CodingStandards.rst | |
parent | 26d628d6ce20548dcb7c99a9519b9034bbf9f5e7 (diff) |
Delete LLVM_DELETED_FUNCTION from coding standards
It didn't seem worth leaving behind a guideline to use '= delete' to
make a class uncopyable. That's a well known C++ design pattern.
Reported on the mailing list and in PR22724.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/CodingStandards.rst')
-rw-r--r-- | docs/CodingStandards.rst | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/docs/CodingStandards.rst b/docs/CodingStandards.rst index 221c431320ce..59fbd72e9bfd 100644 --- a/docs/CodingStandards.rst +++ b/docs/CodingStandards.rst @@ -1301,34 +1301,6 @@ that the enum expression may take any representable value, not just those of individual enumerators. To suppress this warning, use ``llvm_unreachable`` after the switch. -Use ``LLVM_DELETED_FUNCTION`` to mark uncallable methods -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Prior to C++11, a common pattern to make a class uncopyable was to declare an -unimplemented copy constructor and copy assignment operator and make them -private. This would give a compiler error for accessing a private method or a -linker error because it wasn't implemented. - -With C++11, we can mark methods that won't be implemented with ``= delete``. -This will trigger a much better error message and tell the compiler that the -method will never be implemented. This enables other checks like -``-Wunused-private-field`` to run correctly on classes that contain these -methods. - -For compatibility with MSVC, ``LLVM_DELETED_FUNCTION`` should be used which -will expand to ``= delete`` on compilers that support it. These methods should -still be declared private. Example of the uncopyable pattern: - -.. code-block:: c++ - - class DontCopy { - private: - DontCopy(const DontCopy&) LLVM_DELETED_FUNCTION; - DontCopy &operator =(const DontCopy&) LLVM_DELETED_FUNCTION; - public: - ... - }; - Don't evaluate ``end()`` every time through a loop ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |