[libcxx-commits] [libcxx] 0004442 - [libcxx] Update optional star operator to be noexcept.

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 1 10:43:58 PDT 2021


Author: zoecarver
Date: 2021-07-01T10:42:46-07:00
New Revision: 000444214f1658de9905533231f4c80fde2b7f1b

URL: https://github.com/llvm/llvm-project/commit/000444214f1658de9905533231f4c80fde2b7f1b
DIFF: https://github.com/llvm/llvm-project/commit/000444214f1658de9905533231f4c80fde2b7f1b.diff

LOG: [libcxx] Update optional star operator to be noexcept.

Differential Revision: https://reviews.llvm.org/D105296

Added: 
    

Modified: 
    libcxx/include/optional
    libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp
    libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp
    libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const_rvalue.pass.cpp
    libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_rvalue.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/optional b/libcxx/include/optional
index 0e6c1b88f52cf..118db66a4abc9 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -906,7 +906,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     constexpr
     const value_type&
-    operator*() const&
+    operator*() const& noexcept
     {
         _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
         return this->__get();
@@ -915,7 +915,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     constexpr
     value_type&
-    operator*() &
+    operator*() & noexcept
     {
         _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
         return this->__get();
@@ -924,7 +924,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     constexpr
     value_type&&
-    operator*() &&
+    operator*() && noexcept
     {
         _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
         return _VSTD::move(this->__get());
@@ -933,7 +933,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     constexpr
     const value_type&&
-    operator*() const&&
+    operator*() const&& noexcept
     {
         _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
         return _VSTD::move(this->__get());

diff  --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp
index 98216df242cce..5b04e5a35aafa 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp
@@ -44,6 +44,7 @@ int main(int, char**)
     {
         optional<X> opt; ((void)opt);
         ASSERT_SAME_TYPE(decltype(*opt), X&);
+        LIBCPP_STATIC_ASSERT(noexcept(*opt));
         // ASSERT_NOT_NOEXCEPT(*opt);
         // FIXME: This assertion fails with GCC because it can see that
         // (A) operator*() is constexpr, and

diff  --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp
index f61cfcee75066..f323cd1a5e405 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp
@@ -37,6 +37,7 @@ int main(int, char**)
     {
         const optional<X> opt; ((void)opt);
         ASSERT_SAME_TYPE(decltype(*opt), X const&);
+        LIBCPP_STATIC_ASSERT(noexcept(*opt));
         // ASSERT_NOT_NOEXCEPT(*opt);
         // FIXME: This assertion fails with GCC because it can see that
         // (A) operator*() is constexpr, and

diff  --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const_rvalue.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const_rvalue.pass.cpp
index bc6745de161d8..68591c5e2dbcb 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const_rvalue.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_const_rvalue.pass.cpp
@@ -37,6 +37,7 @@ int main(int, char**)
     {
         const optional<X> opt; ((void)opt);
         ASSERT_SAME_TYPE(decltype(*std::move(opt)), X const &&);
+        LIBCPP_STATIC_ASSERT(noexcept(*opt));
         // ASSERT_NOT_NOEXCEPT(*std::move(opt));
         // FIXME: This assertion fails with GCC because it can see that
         // (A) operator*() is constexpr, and

diff  --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_rvalue.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_rvalue.pass.cpp
index c8ee573aea9ad..67edbb903353e 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_rvalue.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.observe/dereference_rvalue.pass.cpp
@@ -44,6 +44,7 @@ int main(int, char**)
     {
         optional<X> opt; ((void)opt);
         ASSERT_SAME_TYPE(decltype(*std::move(opt)), X&&);
+        LIBCPP_STATIC_ASSERT(noexcept(*opt));
         // ASSERT_NOT_NOEXCEPT(*std::move(opt));
         // FIXME: This assertion fails with GCC because it can see that
         // (A) operator*() is constexpr, and


        


More information about the libcxx-commits mailing list