summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcxx/include/any9
-rw-r--r--libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp66
-rw-r--r--libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp8
-rw-r--r--libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp4
-rw-r--r--libcxx/test/std/utilities/any/any.nonmembers/any.cast/rvalue_any_cast_request_lvalue.fail.cpp36
-rw-r--r--libcxx/www/upcoming_meeting.html10
6 files changed, 84 insertions, 49 deletions
diff --git a/libcxx/include/any b/libcxx/include/any
index 69fdbddd621..8fe9e8fe867 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -579,7 +579,8 @@ _ValueType any_cast(any const & __v)
{
using _RawValueType = __uncvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType const &>::value,
- "ValueType is required to be a reference or a CopyConstructible type");
+ "ValueType is required to be a const lvalue reference "
+ "or a CopyConstructible type");
auto __tmp = _VSTD::any_cast<add_const_t<_RawValueType>>(&__v);
if (__tmp == nullptr)
__throw_bad_any_cast();
@@ -592,7 +593,8 @@ _ValueType any_cast(any & __v)
{
using _RawValueType = __uncvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType &>::value,
- "ValueType is required to be a reference or a CopyConstructible type");
+ "ValueType is required to be an lvalue reference "
+ "or a CopyConstructible type");
auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
if (__tmp == nullptr)
__throw_bad_any_cast();
@@ -605,7 +607,8 @@ _ValueType any_cast(any && __v)
{
using _RawValueType = __uncvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType>::value,
- "ValueType is required to be an rvalue reference or a CopyConstructible type");
+ "ValueType is required to be an rvalue reference "
+ "or a CopyConstructible type");
auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
if (__tmp == nullptr)
__throw_bad_any_cast();
diff --git a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp
new file mode 100644
index 00000000000..07578a28e82
--- /dev/null
+++ b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <any>
+
+// template <class ValueType>
+// ValueType any_cast(any &&);
+
+// Try and use the rvalue any_cast to cast to an lvalue reference
+
+#include <any>
+
+struct TestType {};
+using std::any;
+using std::any_cast;
+
+void test_const_lvalue_cast_request_non_const_lvalue()
+{
+ const any a;
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
+ // expected-error@any:* {{binding value of type 'const TestType' to reference to type 'TestType' drops 'const' qualifier}}
+ any_cast<TestType &>(a); // expected-note {{requested here}}
+
+ const any a2(42);
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
+ // expected-error@any:* {{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}}
+ any_cast<int&>(a2); // expected-note {{requested here}}
+}
+
+void test_lvalue_any_cast_request_rvalue()
+{
+ any a;
+ // expected-error@any:* {{static_assert failed "ValueType is required to be an lvalue reference or a CopyConstructible type"}}
+ any_cast<TestType &&>(a); // expected-note {{requested here}}
+
+ any a2(42);
+ // expected-error@any:* {{static_assert failed "ValueType is required to be an lvalue reference or a CopyConstructible type"}}
+ any_cast<int&&>(a2); // expected-note {{requested here}}
+}
+
+void test_rvalue_any_cast_request_lvalue()
+{
+ any a;
+ // expected-error@any:* {{static_assert failed "ValueType is required to be an rvalue reference or a CopyConstructible type"}}
+ // expected-error@any:* {{non-const lvalue reference to type 'TestType' cannot bind to a temporary}}
+ any_cast<TestType &>(std::move(a)); // expected-note {{requested here}}
+
+ // expected-error@any:* {{static_assert failed "ValueType is required to be an rvalue reference or a CopyConstructible type"}}
+ // expected-error@any:* {{non-const lvalue reference to type 'int' cannot bind to a temporary}}
+ any_cast<int&>(42);
+}
+
+int main()
+{
+ test_const_lvalue_cast_request_non_const_lvalue();
+ test_lvalue_any_cast_request_rvalue();
+ test_rvalue_any_cast_request_lvalue();
+}
diff --git a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp
index 59294e78085..3f6955a8cbc 100644
--- a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp
+++ b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp
@@ -29,18 +29,18 @@ int main()
any a;
// expected-error@any:* {{binding value of type 'const TestType' to reference to type 'TestType' drops 'const' qualifier}}
- // expected-error@any:* {{static_assert failed "ValueType is required to be a reference or a CopyConstructible type"}}
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
any_cast<TestType &>(static_cast<any const&>(a)); // expected-note {{requested here}}
// expected-error@any:* {{cannot cast from lvalue of type 'const TestType' to rvalue reference type 'TestType &&'; types are not compatible}}
- // expected-error@any:* {{static_assert failed "ValueType is required to be a reference or a CopyConstructible type"}}
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
any_cast<TestType &&>(static_cast<any const&>(a)); // expected-note {{requested here}}
// expected-error@any:* {{binding value of type 'const TestType2' to reference to type 'TestType2' drops 'const' qualifier}}
- // expected-error@any:* {{static_assert failed "ValueType is required to be a reference or a CopyConstructible type"}}
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
any_cast<TestType2 &>(static_cast<any const&&>(a)); // expected-note {{requested here}}
// expected-error@any:* {{cannot cast from lvalue of type 'const TestType2' to rvalue reference type 'TestType2 &&'; types are not compatible}}
- // expected-error@any:* {{static_assert failed "ValueType is required to be a reference or a CopyConstructible type"}}
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
any_cast<TestType2 &&>(static_cast<any const&&>(a)); // expected-note {{requested here}}
}
diff --git a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp
index 13e1a556086..ed4b96d644d 100644
--- a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp
+++ b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp
@@ -42,11 +42,11 @@ struct no_move {
int main() {
any a;
- // expected-error@any:* {{static_assert failed "ValueType is required to be a reference or a CopyConstructible type"}}
+ // expected-error@any:* {{static_assert failed "ValueType is required to be an lvalue reference or a CopyConstructible type"}}
// expected-error@any:* {{static_cast from 'no_copy' to 'no_copy' uses deleted function}}
any_cast<no_copy>(static_cast<any&>(a)); // expected-note {{requested here}}
- // expected-error@any:* {{static_assert failed "ValueType is required to be a reference or a CopyConstructible type"}}
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
// expected-error@any:* {{static_cast from 'const no_copy' to 'no_copy' uses deleted function}}
any_cast<no_copy>(static_cast<any const&>(a)); // expected-note {{requested here}}
diff --git a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/rvalue_any_cast_request_lvalue.fail.cpp b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/rvalue_any_cast_request_lvalue.fail.cpp
deleted file mode 100644
index 76df14c33aa..00000000000
--- a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/rvalue_any_cast_request_lvalue.fail.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03, c++11, c++14
-
-// <any>
-
-// template <class ValueType>
-// ValueType any_cast(any &&);
-
-// Try and use the rvalue any_cast to cast to an lvalue reference
-
-#include <any>
-
-struct TestType {};
-
-int main()
-{
- using std::any;
- using std::any_cast;
-
- any a;
- // expected-error@any:* {{static_assert failed "ValueType is required to be an rvalue reference or a CopyConstructible type"}}
- // expected-error@any:* {{non-const lvalue reference to type 'TestType' cannot bind to a temporary}}
- any_cast<TestType &>(std::move(a)); // expected-note {{requested here}}
-
- // expected-error@any:* {{static_assert failed "ValueType is required to be an rvalue reference or a CopyConstructible type"}}
- // expected-error@any:* {{non-const lvalue reference to type 'int' cannot bind to a temporary}}
- any_cast<int&>(42);
-}
diff --git a/libcxx/www/upcoming_meeting.html b/libcxx/www/upcoming_meeting.html
index 4607bb3b226..ec447b1fc37 100644
--- a/libcxx/www/upcoming_meeting.html
+++ b/libcxx/www/upcoming_meeting.html
@@ -127,8 +127,8 @@
<tr><td><a href="http://wg21.link/LWG2760">2760</a></td><td>non-const basic_string::data should not invalidate iterators</td><td>Issaquah</td><td>Nothing to do</td></tr>
<tr><td><a href="http://wg21.link/LWG2765">2765</a></td><td>Did LWG 1123 go too far?</td><td>Issaquah</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2767">2767</a></td><td>not_fn call_wrapper can form invalid types</td><td>Issaquah</td><td></td></tr>
- <tr><td><a href="http://wg21.link/LWG2768">2768</a></td><td>any_cast and move semantics</td><td>Issaquah</td><td></td></tr>
-<!-- <tr><td><a href="http://wg21.link/LWG2769">2769</a></td><td>Redundant const in the return type of any_cast(const any&)</td><td>Issaquah</td><td></td></tr> -->
+ <tr><td><a href="http://wg21.link/LWG2768">2768</a></td><td>any_cast and move semantics</td><td>Issaquah</td><td>Resolved by LWG 2769</td></tr>
+ <tr><td><a href="http://wg21.link/LWG2769">2769</a></td><td>Redundant const in the return type of any_cast(const any&)</td><td>Issaquah</td><td>Implemented in trunk</td></tr>
<tr><td><a href="http://wg21.link/LWG2771">2771</a></td><td>Broken Effects of some basic_string::compare functions in terms of basic_string_view</td><td>Issaquah</td><td>We already do this</td></tr>
<tr><td><a href="http://wg21.link/LWG2773">2773</a></td><td>Making std::ignore constexpr</td><td>Issaquah</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2777">2777</a></td><td>basic_string_view::copy should use char_traits::copy</td><td>Issaquah</td><td>Patch Ready</td></tr>
@@ -205,8 +205,10 @@
<li>2760 - This is just wording cleanup; no code or test changes needed.</li>
<li>2765 - is this just wording cleanup????? I don't think this actually requires code changes. </li>
<li>2767 - </li>
-<li>2768 - <i>std::any</i></li>
-<!-- <li>2769 - <i>std::any</i></li> -->
+<li>2768 - <i>std::any</i>: There is no PR for this issue. It is resolved by LWG 2769. </li>
+<li>2769 - <i>std::any</i>: The PR looks good except that
+ <code>remove_reference_t&lt;remove_cv_t&lt;T&gt;&gt;</code> should read
+ <code>remove_cv_t&lt;remove_reference_t&lt;T&gt;&gt;</code>. </li>
<li>2771 - We already do this.</li>
<li>2773 - </li>
<li>2777 - Patch ready; existing tests should suffice</li>
OpenPOWER on IntegriCloud