So I have some fairly simple little classes that I've decided to template-ize so that I could switch between doubles and floats easily, and discover that I get hundreds of warnings about implicit typenames being deprecated. I hate the idea of sprinkling my code with 'typename', because it is such a useless tag [to me...I understand that the compiler needs it], so I typedef'd the offending items. That works great, and frankly the code looks cleaner for it with or without the typename issue.
The problem is that some of these classes get derived from. Naturally, I want to use the same type names in these classes. However, since the derived class is templated, gcc still bitches about implicit typenames. Extremely annoying. In fact, this is more annoying than before...whereas originally iterators were the prime issue, now the underlying containers whine as well.
So far, I've come up with two solutions, both of which require redoing the typedefs within the derived classes. I dislike both of them. Actually, just now it occurs to me that a third solution could involve the preprocessor, but I don't like it much either.
So: are there any other ways of letting the compiler know that an explicit typename isn't neccessary? Without --no-deprecated, that is. I often compile without makefiles, and invariably forget to provide compiler options.
For reference, here's a snippet of code that illustrates the issue:
template<class T> struct Base
{
typedef typename std::vector<T> Vector;
Vector iLikeThisLine;
};
template<class T> struct Derived : Base<T>
{
Vector iHateThisLine;
};
And the output:
Quote:Emphasis added
templates.cpp:12: warning: `typename Derived<T>::Vector' is implicitly a
typename
templates.cpp:12: warning: implicit typename is deprecated, please see the
documentation for details
My favorite solution thus far:
template<class T> struct Derived : Base<T>
{
typedef typename Base<T>::Vector Vector;
Vector iNoLongerHateThisLine;
}
Any suggestions would be appreciated. Everything is working great except these annoying warnings.
CM