Re: std::map
"Duane Hebert" <spoo@flarn.com > wrote in message
news:nsH6b.1873 $dB3.59674@webe r.videotron.net ...[color=blue][color=green]
> >
> > So you've figured out that you need to insert pairs, so the thing in the[/color]
> map[color=green]
> > that the iterator is pointing to is a pair. You also said you want only[/color]
> the[color=green]
> > string, not the whole pair. *it would be the whole pair. In a pair,[/color]
> there[color=green]
> > is a "first" and "second". You want to point to the "second".[/color]
>
> Right but *it.second doesn't work.[/color]
So?
[color=blue]
> One solution would be to do it->first since it returns a reference.
> I don't like this because I think that it obscures the fact that *it is a
> reference.
> The solution that I was looking for was simply (*it).second.[/color]
Yuck. Why would you want to muck it up like that? it->second is perfectly
natural. I think it's crazy to say pointer notation "obscures" the fact
that the dereferenced pointer is a reference. That's like saying you prefer
the statement "It's false that I don't like pie" to the statement "I like
pie." because the second sentence obscures the fact that you don't dislike
it.
"Duane Hebert" <spoo@flarn.com > wrote in message
news:nsH6b.1873 $dB3.59674@webe r.videotron.net ...[color=blue][color=green]
> >
> > So you've figured out that you need to insert pairs, so the thing in the[/color]
> map[color=green]
> > that the iterator is pointing to is a pair. You also said you want only[/color]
> the[color=green]
> > string, not the whole pair. *it would be the whole pair. In a pair,[/color]
> there[color=green]
> > is a "first" and "second". You want to point to the "second".[/color]
>
> Right but *it.second doesn't work.[/color]
So?
[color=blue]
> One solution would be to do it->first since it returns a reference.
> I don't like this because I think that it obscures the fact that *it is a
> reference.
> The solution that I was looking for was simply (*it).second.[/color]
Yuck. Why would you want to muck it up like that? it->second is perfectly
natural. I think it's crazy to say pointer notation "obscures" the fact
that the dereferenced pointer is a reference. That's like saying you prefer
the statement "It's false that I don't like pie" to the statement "I like
pie." because the second sentence obscures the fact that you don't dislike
it.
Comment