Skip to content
Snippets Groups Projects

C++14: Replace comments by '= delete'

Merged Victor Poughon requested to merge cpp14_delete into develop

Summary

Use C++11 deleted functions = delete; syntax.

Rationale

Stricter enforcement of non copy-ability. Note that this grep actually found a minor bug in Modules/Adapters/OSSIMAdapters/src/otbRPCSolverAdapter.cxx which implements deleted functions.

Implementation Details

Classes and files

Applications

Tests

Documentation

Additional notes

Copyright

The copyright owner is CNES and has signed the ORFEO ToolBox Contributor License Agreement

Edited by Victor Poughon

Merge request reports

Approval is optional

Merged by Victor PoughonVictor Poughon 6 years ago (Jun 14, 2018 9:48am UTC)

Merge details

  • Changes merged into develop with 14ec6868.
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Victor Poughon changed title from Cpp14 delete to C++14: Replace comments by '= delete'

    changed title from Cpp14 delete to C++14: Replace comments by '= delete'

  • Victor Poughon changed the description

    changed the description

  • Jordi Inglada mentioned in merge request !131 (merged)

    mentioned in merge request !131 (merged)

  • I think this can be done automatically with https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-delete.html and does not rely on grepping for comments.

  • +1 All C++14 features should be integrated in a automatic way in a feature branch and apply regularly. I've got scripts which apply clang-modernize that I've used in the past to introduce override keyword (@jinglada did the same and make a presentation about it during otb user day hack sessions).

    I think we should start from this.

    Note that it will be interesting to ask itk developers some tips about they did in itk 5.

  • Victor Poughon changed the description

    changed the description

  • Author Contributor

    I propose we work on merging the three C++14 MR I made with our normal process now. It will allow for separate code review and dashboard testing which is nice because these are rather large diffs. We can always run clang-tidy in the future to modernize even more.

    Do you agree with this approach or would you rather close them and do one giant clang-tidy branch later? I agree grepping is a bit less elegant, but I think in that case the resulting diff is just as good, isn't it?

  • I am fine wit grep, sed and even awk or perl if they help moving to a code base which is safer and cleaner. But we should also set up a bot which applies a set of clang-tidy checks for every merge in develop (or even before that).

  • +1. It should be automated.

    BTW, don't forget there are a few different ITK macros that delete copy construction and assignment.

    Another question: shall we keep the comment // deleted on purpose?

  • Author Contributor

    If you have the list of ITK macros please share :)

    About the comment, personnally I think no comment is better since it doesn't really add anything. It's like i+1; // add 1 to i. But in the end I don't mind either way.

  • @poughov if you want to play with grep/find/sed, for a long time I want to rename all .txx in .hxx in OTB :)

    Regarding the MR, +1 to automate this.It will ensure that filters source code remain consistent in the future.

  • In itkMacros.h, I see:

    • ITK_DELETE_FUNCTION
    • ITK_DISALLOW_COPY_AND_ASSIGN

    I can't remember if there used to be another one.

    Regarding comments, I also agree this shouldn't be required. May be we can add a non copyable pedagogical comment in doxygen comments of non-copyable classes like I did in otbOGRDataSourceWrapper.h and in some other files:

    /**
     * .....
     * \note This class has an entity semantics: \em non-copyable, nor \em
     * assignable.
     * ...
     */
    Edited by Luc Hermitte
  • Note that actually, only the base classes require to be non-copyable nor assignable. Children classes inherit this property. Deleting copy-constructor and assignment operator is already a kind of pedagogical annotation in children classes.

  • Author Contributor

    ITK_DELETE_FUNCTION and ITK_DISALLOW_COPY_AND_ASSIGN are not used in OTB

  • This is perfect then.

  • Victor Poughon mentioned in commit 14ec6868

    mentioned in commit 14ec6868

  • Cédric Traizet changed milestone to %7.0.0

    changed milestone to %7.0.0

Please register or sign in to reply
Loading