Edwin Vane | 8ef7fa1 | 2013-04-09 20:49:49 +0000 | [diff] [blame^] | 1 | .. index:: Add-Override Transform |
| 2 | |
| 3 | ====================== |
| 4 | Add-Override Transform |
| 5 | ====================== |
| 6 | |
| 7 | The Add-Override Transform adds the ``override`` specifier to member |
| 8 | functions that override a virtual function in a base class and that |
| 9 | don't already have the specifier. The transform is enabled with the |
| 10 | :option:`-add-override` option of :program:`cpp11-migrate`. |
| 11 | For example: |
| 12 | |
| 13 | .. code-block:: c++ |
| 14 | |
| 15 | class A { |
| 16 | public: |
| 17 | virtual void h() const; |
| 18 | }; |
| 19 | |
| 20 | class B : public A { |
| 21 | public: |
| 22 | void h() const; |
| 23 | |
| 24 | // The declaration of h is transformed to |
| 25 | void h() const override; |
| 26 | }; |
| 27 | |
| 28 | |
| 29 | Known Limitations |
| 30 | ----------------- |
| 31 | * This transform will fail if a method declaration has an inlined method |
| 32 | body and there is a comment between the method declaration and the body. |
| 33 | In this case, the override keyword will incorrectly be inserted at the |
| 34 | end of the comment. |
| 35 | |
| 36 | .. code-block:: c++ |
| 37 | |
| 38 | class B : public A { |
| 39 | public: |
| 40 | virtual void h() const // comment |
| 41 | { } |
| 42 | |
| 43 | // The declaration of h is transformed to |
| 44 | virtual void h() const // comment override |
| 45 | { } |
| 46 | }; |
| 47 | |