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

Christopher Di Bella via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun May 16 21:26:47 PDT 2021

cjdb added inline comments.

Comment at: libcxx/docs/Cxx2bStatusPaperStatus.csv:13
 "`P2259R1 <https://wg21.link/P2259R1>`__","LWG","Repairing input range adaptors and counted_iterator","February 2021","",""
+"`P2231R1 <https://wg21.link/P2231R1>`__","LWG","Missing constexpr in std::optional and std::variant","February 2021","|In progress|","13.0"
zoecarver wrote:
> Was this paper accepted yet?
Please read my commit message.

Comment at: libcxx/include/optional:326
+#if _LIBCPP_STD_VER > 17
+        _VSTD::construct_at(_VSTD::addressof(this->__val_), _VSTD::forward<_Args>(__args)...);
zoecarver wrote:
> Is this part of another paper? Should we add a test too?
This is necessary for GCC 11 to like this patch. It the two should be [[ http://eel.is/c++draft/specialized.construct | equivalent ]]; but this one is permissible in a constant expression.

Comment at: libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp:23
 //    Except in the case where it is moving from an empty optional - that could be
 //    made to be constexpr (and libstdc++ does so).
zoecarver wrote:
> Want to update this comment?
This is still relevant for C++17?

Comment at: libcxx/test/std/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp:43
         static_assert(std::is_trivially_destructible<optional<T>>::value, "");
-        static_assert(std::is_literal_type<optional<T>>::value, "");
zoecarver wrote:
> We should still test this pre-c++20, I think. You could group them all together at the end, though.
🤷 `std::is_literal_type` was deprecated in C++17 with the rationale

> The traits had unreliable or awkward interfaces. The `is_literal_type` trait provided no way to detect which subset of constructors and member functions of a type were declared constexpr.

I'm not sure our tests should have something unreliable?

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list