473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

typename liability for inherited typedefs

Please consider the following Parent and Child template classes:

template <class T>
class Parent {
public:
typedef T type;
typedef T& ref;
/* pack of typedefs */
};

template<class T>
class Child: public Parent<T>
type data;
public:
ref get() {return data;}
};

(gcc) warning: `Child<T>::type' is implicitly a typename
implicit typename is deprecated
(same for ref)

which emphasizes the use and importance of `typename' keyword and is
great, unlike MS compiler.... And thus I guess, above code is not
acceptable according to the standards...

But, where does the typename supposed to appear for derived typedefs
(without listing them all over again in Child)?

Jul 23 '05 #1
2 1822
Levent wrote:
Please consider the following Parent and Child template classes:

template <class T>
class Parent {
public:
typedef T type;
typedef T& ref;
/* pack of typedefs */
};

template<class T>
class Child: public Parent<T>
insert:

{
typedef typename Parent<T>::type type;
typedef typename Parent<T>::ref ref;
type data;
public:
ref get() {return data;}
};


[snip]
Best

Kai-Uwe Bux

Jul 23 '05 #2
Levent wrote:
Please consider the following Parent and Child template classes:

template <class T>
class Parent {
public:
typedef T type;
typedef T& ref;
/* pack of typedefs */
};

template<class T>
class Child: public Parent<T>
type data;
public:
ref get() {return data;}
};

(gcc) warning: `Child<T>::type' is implicitly a typename
implicit typename is deprecated
(same for ref)

which emphasizes the use and importance of `typename' keyword and is
great, unlike MS compiler.... And thus I guess, above code is not
acceptable according to the standards...

But, where does the typename supposed to appear for derived typedefs
(without listing them all over again in Child)?


template <class T>
class Parent {
public:
typedef T type;
typedef T& ref;
/* pack of typedefs */
};

template<class T>
class Child: public Parent<T> {
typename Parent<T>::type data;
public:
typename Parent<T>::ref get() {return data;}
};

Regards,
Larry
--
Anti-spam address, change each 'X' to '.' to reply directly.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Steven T. Hatton | last post by:
I wrote this as part of a request for comments on a mailing list. I realized it summarizes much of what I've been saying about the use of #includes in C++. I'm not asking for the same kind of...
1
by: Exits Funnel | last post by:
Hello, I've inherited a bunch of C++ code which was developed on Windows and I'm in the process of trying to port it to Linux/g++. The following is similar to one very small piece of the code:...
1
by: lutorm | last post by:
Hi all, I'm working on migrating my code from KCC to gcc, and I'm having some issues with "implicit typename" warnings from gcc. Essentially, what happens is described by this example: ...
3
by: Generic Usenet Account | last post by:
This is a two-part question. (1) I have implemented a "Datastructure Registry" template class. I am getting no compiler warnings with older compilers, but newer compilers are generating the...
6
by: PengYu.UT | last post by:
Hi, I'm wondering why typename can not be inherented from base class. An example is shown below. If I have to typedef value_type anyway, I think it would be easier to define the 5 types in...
6
by: blah | last post by:
Hi, Is it possible to force the typename of a template to inherit from a particular class? For example, something like this (conceptual; this doesn't compile): class Parent { public: ...
30
by: junky_fellow | last post by:
I was looking at the source code of linux or open BSD. What I found that lots of typedefs were used. For example, consider the offset in a file. It was declared as off_t offset; and off_t is...
7
by: Noah Roberts | last post by:
I have something like the following: template<ENUM X, int I = 0> class Generic { .... }; typedef Generic<Val1> v1_type; typedef Generic<Val2> v2_type;
1
by: pauldepstein | last post by:
While reading some source code, I saw a variable called "end" of type "time". So I investigated what the type "time" meant and saw that time was a typedef for "Real". So what does "Real" mean? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.