473,698 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does the typename keyword make sense here?

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:

//Begin test1.cpp
template<class B>
class CHB
{ };

template <typename B>

struct BCBT
{
typedef typename CHB<B> BCB;
};
//End test1.cpp

When I try to compile the above, g++ complains thusly:

test1.cpp:9 syntax error before ';' token.

Presumably, this code compiles under MS Visual Studio 7.1. If I remove
the 'typename' from line nine, it's compilable under g++. Two questions
then:

1) Is it legal. In other words, should g++ complain?
2) If it is legal, what does it do? It's not clear to me what purpose
typname would serve in this particular context.

Thanks!

-exits

Jul 22 '05 #1
1 1166

"Exits Funnel" <ex************ ***@yahoo.com> wrote in message
Hello,

When I try to compile the above, g++ complains thusly: [snip] test1.cpp:9 syntax error before ';' token.

Presumably, this code compiles under MS Visual Studio 7.1. If I remove
the 'typename' from line nine, it's compilable under g++. Two questions
then:

1) Is it legal. In other words, should g++ complain?
No, it isn't . g++ is correct.
2) If it is legal, what does it do? It's not clear to me what purpose
typname would serve in this particular context.


Sharad
Jul 22 '05 #2

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

Similar topics

10
5410
by: Alexander Malkis | last post by:
What's the semantical/syntactical difference between two keywords "class" and "typename" (apart from different spelling)? -- Best regards, Alex. PS. To email me, remove "loeschedies" from the email address given.
2
2080
by: Anonymous | last post by:
I'm trying to port code from VC.net to VC.net 2003. Here's a typical piece of code that's often used: template<class T> class PseudoContainer { typedef T::iterator iterator; // this line will change in the next example... };
2
2696
by: Chris Foster | last post by:
Hi, I'm having some difficulty using types which are defined in a base class inside a derived class. The problem crops up using template classes. The following test code encapsulates what I'd like to do, but doesn't compile with g++ (v3.3.3). //--------------------------------------------------------- // A = base class template <typename T>
13
1706
by: Staffan Langin | last post by:
Hello, In the following code-snippet, template<class Base> class Foo : public Base {
9
3343
by: Kobe | last post by:
Is there any difference in: template <class T> vs. template <typename T> ?
6
1377
by: 466 | last post by:
Hi all, I have this member in a template class: bool opsInsert(int nId, T pObj){ pairRet = insert(typename std::map<int,T>::value_type(nId, pObj)); } which does compile with gcc but not with cl.exe (Windows). If I remove the typename keyword, the code does not compile with gcc, but compiles witc cl.exe....
7
2121
by: StephQ | last post by:
First of all: distinction of keywords typename and class in template arguments. Accoarding to a post in a well known moderated group: "There are three possibilities for template arguments: 1) type as in "template <typename T>" or "template <class T>" 2) non-type as in "template <int N>" 3) class template as in "template <template<typenameclass C>" "
5
425
by: Jess | last post by:
Hello, I've seen two forms of template declarations template<typename T> class A{...}; and template<class T>
21
1448
by: Ray Cassick | last post by:
I can't believe why I had not noticed this before and why I never asked it before... When defining a string why is it not required to use the new keyword? Like: Dim a As String = New String You can do it when using the string type with some arguments in the constructor but it look like there is no empty constructor on the String class.
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.