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

checked_cast improvements

    • Service Arch

      • Unconditionally return the result of a static_cast, not dynamic_cast.

      Only do the dynamic_cast in debug builds as a look-see. We don't want interferences from dynamic_cast's capability to do side-casts, producing code that only compiles in debug builds.

      • Add a sfinae check on checked_cast so it only participates in overload resolution when a static_cast would succeed.

      References:

      Realm's checked_cast import:
      https://github.com/realm/realm-core/pull/4331/files#diff-e5bfb8e3654dd2c72e622d276e0cde39f22951a14d18c28631676808c51bc8ce

      Possible improvement on that from using stdx::is_detected.
      https://gcc.godbolt.org/z/dj57bT

      Suggested by Mathias in a server-servicearch Slack thread.
      https://mongodb.slack.com/archives/CMLKU7Y1M/p1611141797007100

            Assignee:
            backlog-server-servicearch [DO NOT USE] Backlog - Service Architecture
            Reporter:
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: