[cfe-commits] r124005 - /cfe/trunk/test/SemaCXX/rval-references-examples.cpp
Douglas Gregor
dgregor at apple.com
Fri Jan 21 14:52:47 PST 2011
Author: dgregor
Date: Fri Jan 21 16:52:47 2011
New Revision: 124005
URL: http://llvm.org/viewvc/llvm-project?rev=124005&view=rev
Log:
Add a test for "perfect" forwarding
Modified:
cfe/trunk/test/SemaCXX/rval-references-examples.cpp
Modified: cfe/trunk/test/SemaCXX/rval-references-examples.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/rval-references-examples.cpp?rev=124005&r1=124004&r2=124005&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/rval-references-examples.cpp (original)
+++ cfe/trunk/test/SemaCXX/rval-references-examples.cpp Fri Jan 21 16:52:47 2011
@@ -88,3 +88,25 @@
return p;
}
+
+namespace perfect_forwarding {
+ struct A { };
+
+ struct F0 {
+ void operator()(A&, const A&, A&&, const A&&, A&&, const A&&); // expected-note{{candidate function not viable: 5th argument ('const perfect_forwarding::A') would lose const qualifier}}
+ };
+
+ template<typename F, typename ...Args>
+ void forward(F f, Args &&...args) {
+ f(static_cast<Args&&>(args)...); // expected-error{{no matching function for call to object of type 'perfect_forwarding::F0'}}
+ }
+
+ template<typename T> T get();
+
+ void test_forward() {
+ forward(F0(), get<A&>(), get<A const&>(), get<A>(), get<const A>(),
+ get<A&&>(), get<const A&&>());
+ forward(F0(), get<A&>(), get<A const&>(), get<A>(), get<const A>(), // expected-note{{in instantiation of function template specialization 'perfect_forwarding::forward<perfect_forwarding::F0, perfect_forwarding::A &, const perfect_forwarding::A &, perfect_forwarding::A, const perfect_forwarding::A, const perfect_forwarding::A, const perfect_forwarding::A>' requested here}}
+ get<const A&&>(), get<const A&&>());
+ }
+};
More information about the cfe-commits
mailing list