summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/utility/forward/forward.fail.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/utilities/utility/forward/forward.fail.cpp')
-rw-r--r--libcxx/test/std/utilities/utility/forward/forward.fail.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/utility/forward/forward.fail.cpp b/libcxx/test/std/utilities/utility/forward/forward.fail.cpp
new file mode 100644
index 00000000000..a3bb890482e
--- /dev/null
+++ b/libcxx/test/std/utilities/utility/forward/forward.fail.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+#include "test_macros.h"
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+#if TEST_STD_VER >= 11
+ {
+ std::forward<A&>(source()); // expected-note {{requested here}}
+ // expected-error@type_traits:* 1 {{static_assert failed "can not forward an rvalue as an lvalue"}}
+ }
+#else
+ {
+ std::forward<A&>(source()); // expected-error {{no matching function for call to 'forward'}}
+ }
+#endif
+ {
+ const A ca = A();
+ std::forward<A&>(ca); // expected-error {{no matching function for call to 'forward'}}
+ }
+ {
+ std::forward<A&>(csource()); // expected-error {{no matching function for call to 'forward'}}
+ }
+ {
+ const A ca = A();
+ std::forward<A>(ca); // expected-error {{no matching function for call to 'forward'}}
+ }
+ {
+ std::forward<A>(csource()); // expected-error {{no matching function for call to 'forward'}}
+ }
+ {
+ A a;
+ std::forward(a); // expected-error {{no matching function for call to 'forward'}}
+ }
+}
OpenPOWER on IntegriCloud