1 // I, Howard Hinnant, hereby place this code in the public domain.
3 // Test the "Augmented" template argument deduction when binding an lvalue to an rvalue reference.
6 // { dg-options "-std=c++0x" }
8 template <bool> struct sa;
9 template <> struct sa<true> {};
11 template <class T, T v>
12 struct integral_constant
14 static const T value = v;
16 typedef integral_constant<T, v> type;
19 typedef integral_constant<bool, true> true_type;
20 typedef integral_constant<bool, false> false_type;
22 template <class T> struct is_lvalue_reference : public integral_constant<bool, false> {};
23 template <class T> struct is_lvalue_reference<T&> : public integral_constant<bool, true> {};
25 template <class T> struct is_rvalue_reference : public integral_constant<bool, false> {};
26 template <class T> struct is_rvalue_reference<T&&> : public integral_constant<bool, true> {};
28 template <bool is_lvalue_ref, bool is_rvalue_ref, class T>
32 sa<is_lvalue_reference<T&&>::value == is_lvalue_ref> t1;
33 sa<is_rvalue_reference<T&&>::value == is_rvalue_ref> t2;
36 template <bool is_lvalue_ref, bool is_rvalue_ref, class T>
40 sa<is_lvalue_reference<const T&&>::value == is_lvalue_ref> t1;
41 sa<is_rvalue_reference<const T&&>::value == is_rvalue_ref> t2;
44 template <bool is_lvalue_ref, bool is_rvalue_ref, class T>
48 sa<is_lvalue_reference<T*&&>::value == is_lvalue_ref> t1;
49 sa<is_rvalue_reference<T*&&>::value == is_rvalue_ref> t2;
56 A source() {return A();}
57 A* sourcep() {return 0;}
61 test1<true, false>(a);
62 test1<false, true>(source());
63 test2<false, true>(a);
64 test2<false, true>(source());
65 test3<false, true>(&a);
66 test3<false, true>(sourcep());