2 // { dg-do compile { target c++11 } }
4 template<class T> struct remove_reference { typedef T type; };
5 template<class T> struct remove_reference<T&> { typedef T type; };
6 template<class T> struct remove_reference<T&&> { typedef T type; };
8 template<class T> struct is_lvalue_reference { static const bool value = false; };
9 template<class T> struct is_lvalue_reference<T&> { static const bool value = true; };
11 template <bool B, class U, class V> struct conditional;
12 template <class U, class V> struct conditional<true, U, V> { typedef U type; };
13 template <class U, class V> struct conditional<false, U, V> { typedef V type; };
15 template<typename _Tp> constexpr _Tp&&
16 forward(typename remove_reference<_Tp>::type& __t) noexcept
17 { return static_cast<_Tp&&>(__t); }
19 ///////////////////////////////////////////////////////////////////////////////
21 template <typename C> struct member_forward
23 typedef typename remove_reference <C>::type::type T;
24 typedef typename conditional
26 is_lvalue_reference <C &&>::value,
32 template <typename C> using member_forward_t = typename member_forward <C>::type;
34 ///////////////////////////////////////////////////////////////////////////////
36 template <int , typename > struct __get;
37 template < typename T> struct __get <0, T>
39 constexpr static auto value (T arg)
40 -> decltype ((forward <member_forward_t <T>> (arg.t)))
42 return forward <member_forward_t <T>> (arg.t);
46 template <int N, typename T> constexpr auto get (T && arg)
47 -> decltype (__get <N, T &&>::value (forward <T> (arg)))
49 return __get <N, T &&>::value (forward <T> (arg));
52 ///////////////////////////////////////////////////////////////////////////////
54 template <typename T> struct S
59 template <typename U> constexpr S (U && u) : t (forward <U> (u)) {}
61 static_assert (get <0> (S <int &&> (1)) == 1, ""); // g++ 4.9 passes, g++ trunk r217559 fails