[libcxx-commits] [PATCH] D102119: [libcxx][optional] adds missing constexpr operations
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 20 10:49:07 PDT 2021
ldionne requested changes to this revision.
ldionne added inline comments.
This revision now requires changes to proceed.
================
Comment at: libcxx/include/optional:72
// 23.6.9, specialized algorithms
- template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below );
+ template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below ); // constexpr in C++20
template <class T> constexpr optional<see below > make_optional(T&&);
----------------
Should be `// constexpr in C++2b (in C++20 as an extension)` or something along those lines, just to acknowledge that we're supporting that as an extension.
================
Comment at: libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp:233
test_one_arg<const T>();
+#if TEST_STD_VER >= 20 && !defined(TEST_COMPILER_GCC)
+ static_assert(test_one_arg<T>());
----------------
This should be:
```
#if TEST_STD_VER > 20 || (TEST_STD_VER >= 20 && defined(_LIBCPP_VER))
```
Basically, test it in C++2b, or in C++20 but only when testing libc++, since it is out own extension. Otherwise, a conforming implementation will fail the test suite in C++20 mode because they don't implement `constexpr` for `std::optional`. This applies everywhere.
Also, what's the deal with GCC? If it fails those tests, we should first report the issue to GCC and then use some `XFAIL` markup to disable it instead.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102119/new/
https://reviews.llvm.org/D102119
More information about the libcxx-commits
mailing list