Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-42081

Map helpers for strict use

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Dev Tools 2019-09-09, Dev Tools 2019-09-09, Dev Tools 2019-09-23

    Description

      I recently ended up creating translation unit-static functions for more strict access patterns with stdx::unordered_map/_set. I suspect that a set of helpers with invariants might be more useful to the codebase at large:

      • getOrInvariant() which invariants that the key already exists (roughly equivalent to at()).
      • emplaceOrInvariant() which invariants that the key did not already exist.
      • eraseOrInvariant() which invariants that the key existed and will no longer.

      This set of operations allows a developer to confidently use a map or set to contain a unique set of initialized objects.

      Attachments

        Activity

          People

            billy.donahue@mongodb.com Billy Donahue
            ben.caimano@mongodb.com Benjamin Caimano (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: