mantid icon indicating copy to clipboard operation
mantid copied to clipboard

Migrate from boost::optional to std::optional - c++17

Open peterfpeterson opened this issue 6 months ago • 0 comments

In interest of using compiler features over library features, move from boost::optional to std::optional which has been in the language since C++17. Like other things that have been matured in boost before migrated to the standard, this requires changing

  • #include <boost/optional.h> becomes #include <optional>
  • boost::optional<T> to std::optional<T>
  • get_value_or() becomes value_or()
  • get() becomes value()
  • boost::none becomes std::nullopt

Separately, the following requires special attention to move to using std::optional.

... and a bunch of things in ISIS reflectometry

  • qt/scientific_interfaces/ISISReflectometry/ <- the whole thing
  • Framework/API/inc/MantidAPI/BoostOptionalToAlgorithmProperty.h and cpp files
  • qt/widgets/common/inc/MantidQtWidgets/Common/Batch/ and cpp files

This article gives a nice summary on why optional <T&> is a bad idea. Unfortunately, it is found several places in the ISIS reflectometry GUI.

peterfpeterson avatar Aug 26 '24 13:08 peterfpeterson