Reputation: 97
I have this class:
#include <iostream>
template<typename T, typename... TT>
class List
{
public:
typedef T head;
typedef List<TT...> next;
enum { size = sizeof...(TT)+1 };
};
and this main:
#include <iostream>
#include "List.h"
using namespace std;
template <int T>
struct Int {
enum { value = T };
};
int main() {
typedef List<Int<1>, Int<2>, Int<3>> list;
cout << list::template head.value << endl; // Error
cout << list::size; // Works
return 0;
}
Error message:
error: expected primary-expression before '.' token
cout << list::template head.value << endl;
I would appreciate any help.. I've been trying to solve this for the past half hour and this is probably something very stupid that I just can't put my finger on.
Upvotes: 0
Views: 45
Reputation: 63154
head
is a type. That means that you can't disambiguate it with template
, nor can you access it with .
. There's not much to do to fix it:
std::cout << list::head::value << std::endl;
Also, please get rid of the using namespace std;
.
Upvotes: 4