From 506528363847233654
X-Google-Thread: f78e5,ac8f7c796c0ee2eb
X-Google-Attributes: gidf78e5,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!kanaga.switch.ch!switch.ch!news-fra1.dfn.de!newsfeed.velia.net!newsfeed.vmunix.org!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: jcoffin@taeus.com (Jerry Coffin)
Newsgroups: comp.std.c++
Subject: Re: std::pair istream >> operator
Date: Mon, 19 Nov 2007 18:18:33 GMT
Organization: TAEUS
Lines: 35
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <MPG.21a93d925d61f8a989a9e@news.sunsite.dk>
References: <a7eb92bf-1ab8-438d-8bca-b6f7cfcc056c@o6g2000hsd.googlegroups.com> <92a741eb-f9f2-40dc-b252-5f53a451af13@w34g2000hsg.googlegroups.com> <84eb137f-aa46-443e-8f6a-912487da73ad@p69g2000hsa.googlegroups.com>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
X-Trace: news.demon.co.uk 1195496335 17068 158.152.254.254 (19 Nov 2007 18:18:55 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Mon, 19 Nov 2007 18:18:55 +0000 (UTC)
X-Original-To: std-c++@mailman.ucar.edu
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: MicroPlanet-Gravity/2.70.2067
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Path: comp-std-cpp-robomod!not-for-mail
X-Received: (from fjh@localhost)
	by mulga.csse.unimelb.edu.au (8.13.8+Sun/8.13.8/Submit) id lAJIIX9a015751;
	Tue, 20 Nov 2007 05:18:33 +1100 (EST)
X-Delivered-To: std-c++@mailman.ucar.edu
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-SMTP-Auth: no
X-Newsgroups: comp.std.c++
Xref: g2news1.google.com comp.std.c++:9648

In article <84eb137f-aa46-443e-8f6a-
912487da73ad@p69g2000hsa.googlegroups.com>, andrey_ryabov@bk.ru says...

[ ... ]

> template <class First, class Second>
> istream & operator >> (istream & in, pair<First, Second> & p) {
> 	return in>>p.first>>p.second;
> }
> 
> In my opinion this is the only possible implementation as it is for
> operators  '<' and '=='.

IMO, this is wrong. The members of a pair are frequently delimited by 
something other than white space, in which case that delimiter has to be 
taken into account. For example, if you write a map out to a stream, you 
frequently use something like a colon to separate the items, in which 
case you have to ignore that colon when you read the data back in.

You can/could accomplish that with a ctype facet that treats your chosen 
delimiter as white space, but that's a rather heavyweight solution, 
especially if only part of what you're reading from the stream is pairs.

-- 
    Later,
    Jerry.

The universe is a figment of its own imagination.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



