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

Duration's implicit converting constructor should be constexpr

    • Fully Compatible
    • Dev Tools 2019-06-03

      While duration's basic constructor is constexpr (as is it's default) allowing for:

      constexpr Seconds foo(20);
      

      It's implicit converting construct is not. Disallowing:

      constexpr Milliseconds foo = Seconds(20);
      

      This reduces the readability of Duration's (compared to standard durations) when constexpr semantics are required.

      I think that in the past we avoided this because it requires a constexpr duration_cast, which is painful to write in C++11. Extended constexpr in C++14 should simplify things though, so I'd like to revisit as part of the C++14 codebase epic.

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            mira.carey@mongodb.com Mira Carey
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: