473,321 Members | 1,916 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,321 software developers and data experts.

make a map out of two maps

Hi.

VC++ 7.0 issues this error when i try to make a container out of two
std::map, i want this container to provide me with o(log(n)) searches in
both types: key_type and mapped_type, and some further features. The code
and the error are like follows. Any workaround will be very helpful.

Thank you very much in advance.
David.

-------- mapa.h ---------

#include<map>

namespace David{

using namespace std;
template<class T1, class T2, class Cmp1 = less<T1>,
class Cmp2 = less<T2>, class A1 = allocator<pair<const T1, T2> >,
class A2 = allocator<pair<const T2, T1> > > class mapa{

private:
map<const T1, T2, Cmp1, A1> map1;
map<const T2, T1, Cmp2, A2> map2;
typedef const T1 key_type;
typedef T2 mapped_type;
};
----------- end of mapa.h ---
----------- main.cpp --------
int main(){
David::mapa<int, char> gMap;
}

-----------------------------

C:\Archivos de programa\Microsoft Visual Studio .NET\Vc7\include\xmemory
(87): error C2535: 'std::allocator<_Ty>::pointer std::allocator
<_Ty>::address(std::allocator<_Ty>::reference) const' : member function
already declared or defined
with
[
_Ty=const std::_Tree<std::_Tmap_traits<const
char,int,std::less<char>,std::allocator<std::pair< const
char,int>>,false>>::key_type
]
Jul 22 '05 #1
1 1399
Manzanita wrote in news:Xn**************************@130.133.1.4:

[snip]
-------- mapa.h ---------

#include<map>

namespace David{

using namespace std;
template<class T1, class T2, class Cmp1 = less<T1>,
class Cmp2 = less<T2>, class A1 = allocator<pair<const T1, T2> >,
class A2 = allocator<pair<const T2, T1> > > class mapa{

private:
map<const T1, T2, Cmp1, A1> map1;
map<const T2, T1, Cmp2, A2> map2;
typedef const T1 key_type;
typedef T2 mapped_type;
};
} /* David:: */
----------- end of mapa.h ---
----------- main.cpp --------
int main(){
David::mapa<int, char> gMap;
}

-----------------------------


With an added closing '}' your code compiled on 2 out of three compilers
I tried, on the third I removed the (unnessasery) const from

map<const T1, T2, Cmp1, A1> map1;
map<const T2, T1, Cmp2, A2> map2;

I.e. changed it to:

map<T1, T2, Cmp1, A1> map1;
map<T2, T1, Cmp2, A2> map2;

And it compiled ok. I don't currently have VC 7.0 installed, but FWIW
you code compiled unmodified on VC7.1.

[snip]

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #2

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

Similar topics

4
by: Jeff Sandys | last post by:
I'm trying to write a mapping function for genealogy. I want to read a gedcom database and plot an icon at a geographic location based on a user's query. Can you help me find: 1) A python...
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
10
by: wim | last post by:
I need to make a layout of a company building, preferably one which can be zoomed and dragged. Knowing that Google Maps does something like that (but much more advanced), I was wondering how I can...
3
by: Sean | last post by:
Have you ever wanted to add the great features inherent in Google Maps? Here is how you do it. ============== == STEP ONE == ============== Create a new MS Access form called frmGoogleMap....
7
by: ATS | last post by:
HOWTO Make a C# UserContol Memory Map to a C++/MFC/EXE Please help, I have a UserControl that I want to have "talk" to a C++/MFC/EXE program that is already running via a memory map. The...
16
by: nleahcim | last post by:
Hi - I am starting to look at doing something that I think will be amazingly difficult. I ideally would like to do this in C, as that is what I am best in. I can handle C++ but I am not particuarly...
6
by: Ian Boyd | last post by:
Every time during development we had to make table changes, we use Control Center. Most of the time, Control Center fails. If you try to "undo all", it doesn't, and you end up losing your identity...
1
by: xahlee | last post by:
Elisp Tutorial: Make Google Earth Xah Lee, 2006-12 This page shows a example of writing a emacs lisp function that creates a Google Earth file, and creates a link to the file, as well a link...
2
by: rn5arn5a | last post by:
I am not sure where I should have posted this question in this newsgroup. Please excuse me if I am wrong. Nowadays, a lot of websites have come with Maps (Google Maps being an example). Can...
0
by: tomPee | last post by:
Hi, I have no idea if this is the right section to post this in. But i thought it maybe belonged here most. The problem i having is actually, most likely really simple. But here i am running...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.