473,508 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is this possible: map of references (map<string&, string&>)

Hello

Is it possible to use map<string&, string&>?

Why I need it. I have a large amount of data obtained from XML file.
I should do processing of this data.

The processing takes many stages, and could be done using std::map
templates. But new instance of std::map is required on each stage.

I would like to avoid additional memory allocation which is done in
map<string, stringcase.

I would like to use smth like map<string&, string&- in this case
there is no need to write additional binary operator
to be used as predicate for map (which would be required if I use
map<string*, string*>)

The questions are:
1. is it possible
2. are any underground problems if I use it

Would like to hear guru comments on it...

Tx,
Alexandru

May 11 '07 #1
3 2368
no, we cannot use map<string&, string&>.
use map<string*, string*instead.

<as*******@gmail.com>
??????:11**********************@y5g2000hsa.googleg roups.com...
Hello

Is it possible to use map<string&, string&>?

Why I need it. I have a large amount of data obtained from XML file.
I should do processing of this data.

The processing takes many stages, and could be done using std::map
templates. But new instance of std::map is required on each stage.

I would like to avoid additional memory allocation which is done in
map<string, stringcase.

I would like to use smth like map<string&, string&- in this case
there is no need to write additional binary operator
to be used as predicate for map (which would be required if I use
map<string*, string*>)

The questions are:
1. is it possible
2. are any underground problems if I use it

Would like to hear guru comments on it...

Tx,
Alexandru

May 11 '07 #2
as*******@gmail.com wrote:
Is it possible to use map<string&, string&>?
No. References are not objects. Consider pointers.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 11 '07 #3
as*******@gmail.com wrote:
>
Is it possible to use map<string&, string&>?
Not directly, but if you've got a library that supports TR1 (or boost,
in a different namespace) you can use
std::tr1::reference_wrapper<stringin both of those places.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
May 12 '07 #4

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

Similar topics

2
1991
by: Kaptain524 | last post by:
Hello, I am using PHP 5.0.4 with Apache 2, on WinXP Pro. This behavior appears to be fundamental however, and should not be affected by platform. It would seem that there is some kind of bug...
12
3955
by: Jeff Lanfield | last post by:
First of all, I apologize if coalescing is not the right term to describe my problem. I have a tree where each node has the same set of attributes (is the same entity) but child nodes should...
5
2297
by: Stephan Hoffmann | last post by:
Hi, I use XML mainly as a source for HTML. HTML browsers 'know' certain entity references like &eacute; or &auml;. When I use XSL to transform XML to HTML or XML, these entities are replaced...
9
10605
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the...
10
1568
by: Steven Spits | last post by:
Hi, Because we have a large WebApp, back in 2002 we decided to use the following method: http://support.microsoft.com/default.aspx?scid=kb;en-us;307467 In short: Create a project "a" at...
6
1404
by: PJ6 | last post by:
I would like to refer to properties in code without having to resort to using a string for the name. AddessOf gives me this ability for methods, but I can't find a single way to point that at the...
9
3815
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
13
10162
by: ragged_hippy | last post by:
Hi, I wanted to create a vector of const references. Something like this: vector<const x&y; where x is a class name. Is this a valid statement? Will this work if I use a reference of 'y'...
0
1377
by: subramanian100in | last post by:
consider the following program: #include <cstdlib> #include <iostream> #include <map> #include <utility> #include <string> using namespace std;
0
7227
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,...
0
7331
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,...
1
7054
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
7501
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...
0
5633
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,...
1
5056
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...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
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 ...
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.