language: C++11 (gcc-4.7.2)
date: 389 days 8 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
namespace Rose
{
    template<typename T>
    struct RemoveReference
    {
        typedef T Type;
    };
 
    template<typename T>
    struct RemoveReference<T &>
    {
        typedef T Type;
    };
 
    template<typename... Elems>
    class Tuple;
    
    template<typename First, typename... Elems>
    class Tuple<First, Elems...>
    {
    public:
        Tuple(First a, Elems... more)
            : More(more...), Element(a)
        {
        }
        
        Tuple<First, Elems...> & operator=(const Tuple<RemoveReference<First>::Type,
                                           RemoveReference<Elems>::Type...> & rhs)
        {
            this->Element = rhs.Element;
            this->More = rhs.More;
 
            return *this;
        }
 
    private:
        Tuple<Elems...> More;
        First Element;
    };
    
    template<typename Only>
    class Tuple<Only>
    {
    public:
        Tuple(Only a) : Element(a)
        {
        }
        
        Tuple<Only> & operator=(const Tuple<RemoveReference<Only>::Type> & rhs)
        {
            this->Element = rhs.Element;
 
            return *this;
        }
 
    private:
        Only Element;
    };
}
 
int main()
{
    Rose::Tuple<int, float, int> t(1, 1.f, 2);
}
prog.cpp:28:75: error: type/value mismatch at argument 1 in template parameter list for 'template<class ... Elems> struct Rose::Tuple'
prog.cpp:28:75: error:   expected a type, got 'Rose::RemoveReference<First>::Type'
prog.cpp:28:75: error: type/value mismatch at argument 1 in template parameter list for 'template<class ... Elems> struct Rose::Tuple'
prog.cpp:28:75: error:   expected a type, got 'Rose::RemoveReference<Elems>::Type ...'
prog.cpp: In member function 'Rose::Tuple<First, Elems ...>& Rose::Tuple<First, Elems ...>::operator=(const int&)':
prog.cpp:30:33: error: request for member 'Element' in 'rhs', which is of non-class type 'const int'
prog.cpp:31:30: error: request for member 'More' in 'rhs', which is of non-class type 'const int'
prog.cpp: At global scope:
prog.cpp:49:72: error: type/value mismatch at argument 1 in template parameter list for 'template<class ... Elems> struct Rose::Tuple'
prog.cpp:49:72: error:   expected a type, got 'Rose::RemoveReference<First>::Type'
prog.cpp: In member function 'Rose::Tuple<Only>& Rose::Tuple<Only>::operator=(const int&)':
prog.cpp:51:33: error: request for member 'Element' in 'rhs', which is of non-class type 'const int'