From 5613885949729512379
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!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!colt.net!peer-uk.news.demon.net!kibo.news.demon.net!mutlu.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: tazmaster@rocketmail.com ("Jim Langston")
Newsgroups: comp.std.c++
Subject: Re: std::pair istream >> operator
Date: Mon, 19 Nov 2007 19:08:53 GMT
Lines: 28
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <Y4l0j.39$xq7.20@newsfe05.lga>
References: <a7eb92bf-1ab8-438d-8bca-b6f7cfcc056c@o6g2000hsd.googlegroups.com>
NNTP-Posting-Host: news.news.demon.net
X-Trace: news.demon.co.uk 1195499341 20943 158.152.254.254 (19 Nov 2007 19:09:01 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Mon, 19 Nov 2007 19:09:01 +0000 (UTC)
X-Original-To: std-c++@mailman.ucar.edu
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-Priority: 3
X-RFC2646: Format=Flowed; Original
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-MSMail-Priority: Normal
X-Received: (from fjh@localhost)
	by mulga.csse.unimelb.edu.au (8.13.8+Sun/8.13.8/Submit) id lAJJ8rcW012799;
	Tue, 20 Nov 2007 06:08:53 +1100 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-NNTP-Posting-Date: Mon, 19 Nov 2007 12:02:16 MST
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-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-Newsgroups: comp.std.c++
X-Original-Bytes: 2624
Xref: g2news1.google.com comp.std.c++:9652

"Andrey" <andrey_ryabov@bk.ru> wrote in message 
news:a7eb92bf-1ab8-438d-8bca-b6f7cfcc056c@o6g2000hsd.googlegroups.com...
> Hello.
> I'm wondering why there is no standard operator defined like the
> following?
>
> template<typename First, typename Second>
> istream & operator >> (istream & in, pair<First, Second> & p) {
> return in>>p.first>>p.second;
> }
>
> I always define it by hand.

Consider, also, that your implemnation can be broken for 
std::pair<std::string, int> since the std::string can contain a space.  In 
which case it might need to be
std::getline( in, p.first );
return in >> p.second;

or even with <int, std::string> you probably want a std::getline for the 
second parameter. 

---
[ 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                      ]



