All Questions

822
votes
5answers
102515 views

Where and why do I have to put the "template" and "typename" keywords?

In templates, where and why do I have to put typename and template on dependent names? What exactly are dependent names anyway? I have the following code: template <typename T, typename Tail> /...
41
votes
3answers
24119 views

When is the "typename" keyword necessary?

Possible Duplicate: Officially, what is typename for? Where and why do I have to put the template and typename keywords? consider the code below: template<class K> class C { stru...
45
votes
5answers
26967 views

Why do I need to use typedef typename in g++ but not VS?

It had been a while since GCC caught me with this one, but it just happened today. But I've never understood why GCC requires typedef typename within templates, while VS and I guess ICC don't. Is the ...
54
votes
6answers
77661 views

C++ Get name of type in template

I'm writing some template classes for parseing some text data files, and as such it is likly the great majority of parse errors will be due to errors in the data file, which are for the most part not ...
32
votes
4answers
41460 views

C++ template typename iterator

Consider the following header file: template <typename T> struct tNode { T Data; //the data contained within this node list<tNode<T>*> SubNodes; /...
28
votes
3answers
3915 views

Use of typename keyword with template function parameters

In C++, the typename keyword is needed so the compiler can disambiguate between nested types and nested values in templates. However, there are certain situations where no ambiguity is possible, such...
13
votes
3answers
4447 views

Why is the keyword "typename" needed before qualified dependent names, and not before qualified independent names?

class A { static int iterator; class iterator { [...] }; [...] }; I (think I) understand the reason why typename is needed here: template <class T> void foo() { typena...
19
votes
3answers
11619 views

Use of typename keyword with typedef and new

Consider this code, template<class T> struct Sample { typename T::X *x; //declare pointer to T's X }; In the above code, the keyword typename is required by the compiler, so that it can...
27
votes
2answers
1607 views

Why does not a template template parameter allow 'typename' after the parameter list

Template template typename? When using template template syntax as in template <template <typename> class T>, it is required to use the keyword class, as using typename gives an error alo...
3
votes
4answers
563 views

When should I use the keyword "typename" when using templates

I've been working lately on a small project, and I couldn't figure out something.. I've been given a .h file that was containing a class, using a typename template. Inside that class there was a priv...

Previous Next