[libcxx-commits] [PATCH] D102119: [libcxx][optional] adds missing constexpr operations

Christopher Di Bella via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat May 8 18:43:59 PDT 2021


cjdb created this revision.
cjdb added reviewers: ldionne, EricWF, tcanens, zoecarver, Mordante, curdeius, Quuxplusone.
cjdb requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Makes the following operations constexpr:

- `std::swap(optional, optional)`
- `optional(optional<U> const&)`
- `optional(optional<U>&&)`
- `~optional()`
- `operator=(nullopt_t)`
- `operator=(U&&)`
- `operator=(optional<U> const&)`
- `operator=(optional<U>&&)`
- `emplace(Args&&...)`
- `emplace(initializer_list<U>, Args&&...)`
- `swap(optional&)`
- `reset()`

P2231 <https://reviews.llvm.org/P2231> is currently marked as tentatively ready for plenary. [LWG
recommends implementers retroactively apply to C++20][1]. This commit
is a bit ahead of the committee, but it's necessary to conveniently
implement _`semiregular-box`_ and _`non-propagating-cache`_, both of
which are required for ranges (otherwise we'll need to reimplement
`std::optional` with these members `constexpr`ified). If LEWG or
plenary decide that P2231 <https://reviews.llvm.org/P2231> shouldn't be adopted, then this commit will
be rolled back, and a detail optional base will appear in its place.

[1]: https://github.com/cplusplus/papers/issues/933


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102119

Files:
  libcxx/include/optional
  libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
  libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
  libcxx/test/std/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp
  libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/const_optional_U.pass.cpp
  libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp
  libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp
  libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/optional_U.pass.cpp
  libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
  libcxx/test/std/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp
  libcxx/test/support/archetypes.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102119.343879.patch
Type: text/x-patch
Size: 34388 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210509/8dae8a45/attachment-0001.bin>


More information about the libcxx-commits mailing list