http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57063

--- Comment #2 from Nikolka <tsoae at mail dot ru> 2013-04-25 07:19:20 UTC ---
The alias is added for convenience - we can quickly test handling of different
types so. It seems that there is no problem with class types and function
types, the error arises when T is a scalar type or an array type:

    #include <string>

    template <class T>
        struct X
    {
        T &&f()
        {
            return static_cast<T &&>(value);
        }
        T &&value;
    };

    enum E {};

    template class X<int>;
    template class X<E>;
    template class X<std::string>;
    template class X<int()>;
    template class X<int[1]>;

test.cpp: In instantiation of ‘T&& X<T>::f() [with T = int]’:
test.cpp:15:20:   required from here
test.cpp:8:43: error: cannot bind ‘int’ lvalue to ‘int&&’
             return static_cast<T &&>(value);
                                           ^
test.cpp: In instantiation of ‘T&& X<T>::f() [with T = E]’:
test.cpp:16:20:   required from here
test.cpp:8:43: error: cannot bind ‘E’ lvalue to ‘E&&’
test.cpp: In instantiation of ‘T&& X<T>::f() [with T = int [1]]’:
test.cpp:19:20:   required from here
test.cpp:8:43: error: cannot bind ‘int [1]’ lvalue to ‘int (&&)[1]’

Reply via email to