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

Duration's implicit converting constructor should be constexpr

    XMLWordPrintable

    Details

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: