doc: Add note about our preference for scoped enumerations ("enum class") #12800

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:document-enum-class-preference changing 1 files +1 −0
  1. practicalswift commented at 3:04 PM on March 27, 2018: contributor

    Add note about our preference for scoped enumerations (enum class).

    Context: #10742

  2. practicalswift force-pushed on Mar 27, 2018
  3. in doc/developer-notes.md:42 in 5cb262bf85 outdated
      38 | @@ -39,6 +39,7 @@ code.
      39 |    - `++i` is preferred over `i++`.
      40 |    - `nullptr` is preferred over `NULL` or `(void*)0`.
      41 |    - `static_assert` is preferred over `assert` where possible. Generally; compile-time checking is preferred over run-time checking.
      42 | +  - `enum class` is preferred over `enum` where possible. Scoped enumerations avoid three potential pitfalls/problems with traditional C++ enumerations: 1.) implicit conversions to int, 2.) name clashes due to enumerators being exported to the surrounding scope, and 3.) inability to specify the underlying type of the enum.
    


    MarcoFalke commented at 3:10 PM on March 27, 2018:

    I had the impression it was possible to specify the type even for the "deprecated" enum.


    practicalswift commented at 3:17 PM on March 27, 2018:

    @MarcoFalke Ah, you're right. Forward declaration of enum:s was fixed in C++11. Will update!


    laanwj commented at 4:17 PM on March 27, 2018:

    It's ok, avoiding scope leak is the best argument for using scoped enums anyway.

  4. MarcoFalke commented at 3:11 PM on March 27, 2018: member

    Concept ACK

  5. doc: Add note about our preference for scoped enumerations ("enum class") 0fee2b4180
  6. practicalswift force-pushed on Mar 27, 2018
  7. MarcoFalke commented at 4:29 PM on March 27, 2018: member

    ACK 0fee2b4180815628bd9be03bbb0217e3f8515b57

  8. laanwj merged this on Mar 27, 2018
  9. laanwj closed this on Mar 27, 2018

  10. laanwj referenced this in commit 2d97611c41 on Mar 27, 2018
  11. PastaPastaPasta referenced this in commit 8dea2ad7a6 on Jul 17, 2020
  12. PastaPastaPasta referenced this in commit 52784085cb on Jul 17, 2020
  13. practicalswift deleted the branch on Apr 10, 2021
  14. DrahtBot locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me