1 // RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
4 // If P is an rvalue reference to a cv-unqualified template parameter
5 // and the argument is an lvalue, the type "lvalue reference to A" is
6 // used in place of A for type deduction.
7 template<typename T
> struct X
{ };
9 template<typename T
> X
<T
> f0(T
&&);
13 template<typename T
> T
prvalue();
14 template<typename T
> T
&& xvalue();
15 template<typename T
> T
& lvalue();
18 X
<int> xi0
= f0(prvalue
<int>());
19 X
<int> xi1
= f0(xvalue
<int>());
20 X
<int&> xi2
= f0(lvalue
<int>());
21 X
<Y
> xy0
= f0(prvalue
<Y
>());
22 X
<Y
> xy1
= f0(xvalue
<Y
>());
23 X
<Y
&> xy2
= f0(lvalue
<Y
>());
26 template<typename T
> X
<T
> f1(const T
&&); // expected-note{{candidate function [with T = int] not viable: no known conversion from 'int' to 'const int &&' for 1st argument}} \
27 // expected-note{{candidate function [with T = Y] not viable: no known conversion from 'Y' to 'const Y &&' for 1st argument}}
30 X
<int> xi0
= f1(prvalue
<int>());
31 X
<int> xi1
= f1(xvalue
<int>());
32 f1(lvalue
<int>()); // expected-error{{no matching function for call to 'f1'}}
33 X
<Y
> xy0
= f1(prvalue
<Y
>());
34 X
<Y
> xy1
= f1(xvalue
<Y
>());
35 f1(lvalue
<Y
>()); // expected-error{{no matching function for call to 'f1'}}
38 namespace std_example
{
39 template <class T
> int f(T
&&);
40 template <class T
> int g(const T
&&); // expected-note{{candidate function [with T = int] not viable: no known conversion from 'int' to 'const int &&' for 1st argument}}
45 int n3
= g(i
); // expected-error{{no matching function for call to 'g'}}