those are the maps: -
multimap<SortKey,T> firstMap;
-
multimap<SearchKey,pair<SortKey,T>*> secondMap;
-
-
-
template <class T,class SortKey, class SearchKey> bool GarageDataBase<T,SortKey,SearchKey>::Add(T data,SortKey key1, SearchKey key2)
-
{
-
multimap<SortKey,T>::iterator it;
-
it=(firstMap.insert(pair<SortKey,T>(key1,data)));
-
pair<SortKey,T> *mizi=&*it;
-
-
secondMap.insert(pair<SearchKey,pair<SortKey,T>*>(key2,mizi));
-
return true;
-
}
-
I am trying to insert a pair into the firstMap and get a pointer to this pair and insert it into the "second" field in the secondMap
so that i could go into my firstMap from the secondmap. -
pair<SortKey,T> *mizi=&*it;
this doesn't compile saying :
error C2440: 'initializing' : cannot convert from 'std::pair<_Ty1,_Ty2> *' to 'std::pair<_Ty1,_Ty2> *'
any idea whats going on or maybe a better way to make it work?
1 2037
As I see it your wamt to have an iterator from firstMap be the data for the pair in seciond Map.
So this would be your secondMap: - multimap<SortKey,multimap<SortKey,int>::iterator > secondMap;
Then you get an iterator from firstMap: - multimap<SortKey,T>::iterator it;
-
it= firstMap.find(key1,data)
and insert it as the data value in secondMap: - pair<SortKey,multimap<SortKey,int>::iterator > mizi;
-
mizi.first = key2;
-
mizi.second = it;
-
secondMap.insert(mizi);
Of course, I may be misunderstanding your purpose. If so, please excuse me and I'll try again.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Neil Zanella |
last post by:
Hello,
I would like to ask how come the design of C++ includes
std::pair. First of all I don't think many programmers
would use it. For starters, what the first and second
members are depends...
|
by: Michael Klatt |
last post by:
I am trying to write an iterator for a std::set that allows the
iterator target to be modified. Here is some relvant code:
template <class Set> // Set is an instance of std::set<>
class...
|
by: JustSomeGuy |
last post by:
in the stl map class I see the use of a function pair and make_pair.
What is the difference between pair and make_pair?
dictionary.insert(std::pair<Key, Value>(k,v));
works as well as:
...
|
by: PengYu.UT |
last post by:
Hi,
Suppose I have a list which contains pointers. I want the pointer got
by dereferencing the iterator be a pointer pointing to a const object.
But std::list<const T*>::const_iterator doens't...
|
by: shawnk |
last post by:
I searched the net to see if other developers have been looking for a
writable iterator in C#. I found much discussion and thus this post.
Currently (C# 2) you can not pass ref and out arguments...
|
by: kietzi |
last post by:
Hello world,
I was wondering whether it would be possible to create a map which uses
a pair of ints as key and a float as value. I have used maps with const
char* as key, but have so far not been...
|
by: flopbucket |
last post by:
Hi,
For the learning experience, I am building a replacement for std::map.
I built a templated red-black tree, etc., and all the basic stuff is
working well. I implemented basic iterators and...
|
by: Dean Card |
last post by:
Okay, so here is the situation. I have need to do some on-the-fly image
creation. I have everything working great except for the last part of it,
applying a perspective type transform to the...
|
by: Saile |
last post by:
I want to give an array the values from the specific multimap's key's values.
multimap<string,int> mymultimap;
multimap<string,int>::iterator it;...
|
by: qlin88 |
last post by:
Hi,
In STL multi-map, the lower_bound, upper_bound,equal_range all
return an iterator. Now ifone wants to iterate from an upper bound
towards a lower bound, what would be the best way to do it?...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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,...
|
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,...
|
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: 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...
|
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: 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,...
| |