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

tassert() should use operator bool()

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 4.9.0
    • None
    • Internal Code
    • Fully Compatible
    • Query Execution 2021-03-22

    Description

      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());
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: