473,587 Members | 2,263 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 2384
no, we cannot use map<string&, string&>.
use map<string*, string*instead.

<as*******@gmai l.com>
??????:11****** *************** *@y5g2000hsa.go oglegroups.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::refer ence_wrapper<st ringin 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
2004
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 in the process that creates the reference when it is being assigned to an array element within itself. If it is already referenced, it just...
12
3965
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 inherit attribute values from parent node. for example, say I have the following table: (nodeId int , color varchar, phone varchar) with two rows ...
5
2307
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 by what they refer to. Is there a way to avoid that?
9
10619
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 table from which I want to delete has two foreign keys that references two other tables and it is also referenced by another table. But this...
10
1579
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 http//localhost/MyWebApp
6
1412
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 Get or Set methods of properties directly. Why don't I want to use a string? Well, I want to know at design time that my property references...
9
3822
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 site for a small club I belong to and one of the features I would like to include is the ability to allow users to upload image files. ...
13
10203
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' somewhere else?
0
1389
by: subramanian100in | last post by:
consider the following program: #include <cstdlib> #include <iostream> #include <map> #include <utility> #include <string> using namespace std;
0
7915
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...
0
8205
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. ...
1
7967
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...
0
8220
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...
0
6619
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...
1
5712
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...
1
2347
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
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.