From 3276648754260580044
X-Google-Thread: f78e5,ac8f7c796c0ee2eb
X-Google-Attributes: gidf78e5,public,usenet
X-Google-Language: ENGLISH,ASCII
Path: g2news1.google.com!news3.google.com!out01b.usenetserver.com!news.usenetserver.com!in02.usenetserver.com!news.usenetserver.com!pd7cy1no!shaw.ca!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: James Kanze <james.kanze@gmail.com>
Newsgroups: comp.std.c++
Subject: Re: std::pair istream >> operator
Date: Tue, 27 Nov 2007 10:46:10 CST
Organization: http://groups.google.com
Lines: 49
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <01a449b0-f514-44ff-9949-5a65d6e2dc46@w34g2000hsg.googlegroups.com>
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> 
	<MPG.21a93d925d61f8a989a9e@news.sunsite.dk> <c6dd44f5-b0eb-45ef-be8b-ee5d410ed626@e4g2000hsg.googlegroups.com> 
	<63447783-3e0d-41f8-98a6-62f69025e631@d50g2000hsf.googlegroups.com> 
	<d76955b6-a58b-4b1d-b9cb-ebf44907f8f0@e1g2000hsh.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1196168026 22169 127.0.0.1 (27 Nov 2007 12:53:46 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 27 Nov 2007 12:53:46 +0000 (UTC)
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
X-SMTP-Auth: no
Complaints-To: groups-abuse@google.com
Injection-Info: w34g2000hsg.googlegroups.com; posting-host=62.160.54.162; 
	posting-account=1W_PtwoAAAA1QoMcl2Z5P6j-DNc8HR3W
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.9) 
	Gecko/20071025 Firefox/2.0.0.9,gzip(gfe),gzip(gfe)
Content-Disposition: inline
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-MIME-Autoconverted: from quoted-printable to 8bit by mulga.csse.unimelb.edu.au id lARCrsoN024701
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Xref: g2news1.google.com comp.std.c++:9693

On Nov 26, 6:42 pm, Martin <wpcm...@hotmail.com> wrote:
> On 21 Nov, 18:54, Andrey <andrey_rya...@bk.ru> wrote:

    [...]
> Then you have the problem with the width stream manipulator.
> Don't know how the tuple streaming handles it but I do know
> that complex got it all wrong.  For complex the width is
> applied to the result string and not the items.
> cout << width(5) << complex(1,2)
> becomes
> "1,2  "
> which makes it impossible to line up the items.  If the width
> is applied to each item you can always use an intermediate
> string stream to limit the width of the result string.

The solution I'd always seen (in pre-standard complex) was to
apply (width()-3)/2 to each of the components of the complex.

> If I could put in a recommendation it would be:
> - Add a separator field to the ios_base structure (default =
> traits::eof() -> ctype.isspace for input and space for output)
> - Add manipulators: separator, setseparator, showseparator,
> noshowseparator (default)
> - Width, fill etc applies to each item (but not the separator)
> - separator is also used to end stream input for string.

None of which addresses the basic problem of outputting
std::pair (or boost::tuple): the fact that the type may have
different semantic signification at different places in the
program.  A format which would be appropriate for e.g. an
element in a map would certainly not be appropriate in other
cases, even if the types are identical.

Although there may be some special cases, my own feeling is that
any use of std::pair (and probably most uses of boost::tuple)
are simply poor programming.

--
James Kanze (GABI Software)             email:james.kanze@gmail.com
Conseils en informatique orient�e objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34

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



