Skip to content
Snippets Groups Projects

added nullopt, in_place and bad_optional_access from std namespace to Dune::Std namespace

Summary

Import types std::nullopt_t, std::in_place_t, and std::bad_optional_access and instances nullopt and in_place of these types into namespace Dune::Std in the file <dune/common/std/optional> in case of DUNE_HAVE_CXX_OPTIONAL is defined.

Motivation

If you have a compiler with c++17 std::optional support, the std implementation is imported into the namespace Dune::Std, but not all Helper classes are imported as well, i.e. nullopt_t, nullopt, in_place_t, in_place and bad_optional_access are missing. So, I neither can use e.g. std::nullopt nor can I use Dune::Std::nullopt, since the first one is defined whenever DUNE_HAVE_CXX_OPTIONAL is set and the second one if it is not set.

Discussion

For the future it has to be decided, whether std::in_place*** is implemented in <dune/common/std/optional> or better in <dune/common/std/utility>, since in the std library it is defined there and used not just for optional but also for variant and any.

Edited by Simon Praetorius

Merge request reports

Pipeline #6762 passed

Pipeline passed for ec10d0a7 on simon.praetorius:issue/missing_nullopt_in_optional

Merged by Jö FahlkeJö Fahlke 6 years ago (Aug 1, 2018 4:43pm UTC)

Loading

Pipeline #11397 passed

Pipeline passed for 76cf27a3 on master

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Simon Praetorius changed the description

    changed the description

  • Any objections to merge this simple completion of the c++17-backport?

  • I'm not quite sure what anonymous namespaces are supposed to achieve (the const already gives nullopt and in_place internal linkage). Normally an anonymous namespace in a header is an error, though in this case it's hard to see how it'd lead to problems (you're not going to instantiate a template with a Dune::nullopt template argument). On the other hand, the existing compatibility implementation uses anonymous namespaces (equally needlessly), so there.

    I guess it's gonna be gone anyway when we require C++17.

  • merged

  • Jö Fahlke mentioned in commit 76cf27a3

    mentioned in commit 76cf27a3

Please register or sign in to reply
Loading