upcxx::optional does not conform to C++17 std::optional interface

Issue #589 wontfix
Amir Kamil created an issue

Our implementation of optional diverges from the standard C++17 interface in several places. For instance:

  • emplace() does not return a reference to the newly created object (fix forthcoming via PR 475).
  • There are several constructor and assignment-operator overloads that we do not implement.
  • operator*() and value() are missing const&& overloads.
  • There are still some residual optional<T&> specializations (comparison operators, std::hash).
  • Comparison operators do not allow comparison between optional<T> and optional<U> or U where U != T.

There may be other diversions as well.

Comments (3)

  1. Amir Kamil reporter

    PR 479 fixes the following:

    • Adds operator*() const&& and value() const&& overloads for compilers that have move accessors.
    • Removes residual optional<T&> specializations.
    • Adds comparisons between optional<T> and optional<U>/U.

    The following is still outstanding:

    • There are several constructor and assignment-operator overloads that we do not implement.

  2. Dan Bonachea

    We don't plan to fix the remaining non-compliances.

    Users encountering limitations of our upcxx::optional shim are advised to build using -std=c++17 to activate the std::optional implementation.

  3. Log in to comment