473,398 Members | 2,525 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,398 software developers and data experts.

using hash_set in gcc3.3

Hi,

My question is about the STL extensions hash_set and hash_map, especially
the SGI versions of these templates. When defining a class like this :

#include <hash_set>
class MyClass : public hash_set<int>
{
// members here.
};

gcc2.95 would compile it without any errors or warnings. When using gcc3.3
however, compilation results in a syntax error (syntax error before '<').
Yes, I included ext/hash_set instead of hash_set, but it still doesn't seem
to recognize the hash_set as a defined template type.

Anyone got any idea what I'm doing wrong? I already tried full
specialization with hash_set<int, hash<int>, eqint, alloc<int> > but this
won't help either.

thanx for any help.
B.B.
Jul 22 '05 #1
5 2319
It's not just a namespace thing?

/Daniel Aarno

Bart Blommerde wrote:
Hi,

My question is about the STL extensions hash_set and hash_map, especially
the SGI versions of these templates. When defining a class like this :

#include <hash_set>
class MyClass : public hash_set<int>
{
// members here.
};

gcc2.95 would compile it without any errors or warnings. When using gcc3.3
however, compilation results in a syntax error (syntax error before '<').
Yes, I included ext/hash_set instead of hash_set, but it still doesn't seem
to recognize the hash_set as a defined template type.

Anyone got any idea what I'm doing wrong? I already tried full
specialization with hash_set<int, hash<int>, eqint, alloc<int> > but this
won't help either.

thanx for any help.
B.B.

Jul 22 '05 #2
> It's not just a namespace thing?

What do you mean exactly? I'm not used to using namespaces, but as far as I
know the only namespace I'm using is std.
Jul 22 '05 #3

"Bart Blommerde" <ba***@xs4all.nl> wrote in message
news:41***********************@news.xs4all.nl...
It's not just a namespace thing?
What do you mean exactly? I'm not used to using namespaces, but as far as

I know the only namespace I'm using is std.


But you aren't, that is the point.

#include <hash_set>
class MyClass : public std::hash_set<int>
{
};

An in any case you should not normally derive from standard containers.

#include <hash_set>
class MyClass
{
private:
std::hash_set<int> mySet;
};

is usually preferred. MyClass has a hash_set, it is not a kind of hash_set.
Therefore membership not inheritance is better.

john
Jul 22 '05 #4
> But you aren't, that is the point.

#include <hash_set>
class MyClass : public std::hash_set<int>
{
};


Well, I just saw in the SGI source files they use a different namespace for
these extensions. I just needed the following addition to my code :

using namespace __gnu_cxx;

This works, but is far from an ideal solution, since my code now doesn't
compile with gcc2.95. Some people just throw in new namespaces far too
easily. :(
B.B.
Jul 22 '05 #5

"Bart Blommerde" <ba***@xs4all.nl> wrote in message
news:41***********************@news.xs4all.nl...
But you aren't, that is the point.

#include <hash_set>
class MyClass : public std::hash_set<int>
{
};
Well, I just saw in the SGI source files they use a different namespace

for these extensions. I just needed the following addition to my code :

using namespace __gnu_cxx;

This works, but is far from an ideal solution, since my code now doesn't
compile with gcc2.95. Some people just throw in new namespaces far too
easily. :(


Apologies, I had completely forgotten that hash_set is not standard.
Although it's likely to become part of the standard at some point, until
then compilers are going to vary.

john
Jul 22 '05 #6

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

Similar topics

4
by: Vasileios | last post by:
Hello could someone help me please. I have the following class definition #include <ext/hash_set> #include "tool.h" class ToolContainer : public QObject {
3
by: Markus Dehmann | last post by:
I have a class "Data" and I store Data pointers in an STL set. But I have millions of inserts and many more lookups, and my profiler found that they cost a lot of runtime. Therefore, I want to...
13
by: Eric | last post by:
I need an effective way (time is my main concern here) to generate 10 000 000 unique alphanumeric strings of 16 characters each. I used STL set and map but after about 5 000 000 entries, it...
5
by: jian | last post by:
I am trying to use the hash_set, but cannot get it work. Here's my code: // file name: hash1.cpp #include <hash_set> int main() { hash_set<int> h; } When I type:
1
by: zs | last post by:
Hi! I get warning message shown below in VS.NET 2k3. Is this deprecated by microsoft or by standard? I need hash_set to store and search small strings (<20 chars long). I'll have less then 300...
2
by: breck | last post by:
I'm having trouble with hash_set's insert. It's not supposed to allow the same element to be insert more than once, but this is what is happening for me. My question is, what function does it use...
4
by: yuyang08 | last post by:
Hello, everyone, I am wondering what is the hash function that is used in hash_map/hash_set. Can I replace it with my own hash function? Any comments on this? Thanks! -Andy
2
by: Pierre Couderc | last post by:
Generally, is there somewhere a good tutorial and examplefor the use of SGI STL hash_set? I am lost in SGI documentation. More specifically, i am trying to use hat I need that a hash_set : ...
5
by: Markus Dehmann | last post by:
Do I have to handle hash collisions in a hash_set myself? I did a test in which I use find() to look for objects in a hash_set. These objects are definitely not contained, but find() sometimes...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
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...

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.