зеркало из https://github.com/microsoft/clang.git
Add a test for "perfect" forwarding
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124005 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
dcfb360f6e
Коммит
5232011c94
|
@ -88,3 +88,25 @@ unique_ptr<int> test_unique_ptr() {
|
|||
|
||||
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&&>());
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче