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

tassert() should use operator bool()

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9.0
    • Affects Version/s: None
    • Component/s: Internal Code
    • Labels:
    • Fully Compatible
    • Query Execution 2021-03-22

      Let's say I have a boost::optional<T>. I would like to be able to write the following:

      boost::optional<T> myT = getT();
      tassert(1234500, "expected a non-none T", myT);
      

      However, today I have to write either

      tassert(1234500, "expected a non-none T", static_cast<bool>(myT));
      

      or

      tassert(1234500, "expected a non-none T", myT.has_value());
      

            Assignee:
            yoonsoo.kim@mongodb.com Yoon Soo Kim
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: