From 4546633274765199962
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!news.glorb.com!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: Martin <wpcmame@hotmail.com>
Newsgroups: comp.std.c++
Subject: Re: std::pair istream >> operator
Date: Mon, 26 Nov 2007 11:42:13 CST
Organization: http://groups.google.com
Lines: 54
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <d76955b6-a58b-4b1d-b9cb-ebf44907f8f0@e1g2000hsh.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>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1195809396 14086 127.0.0.1 (23 Nov 2007 09:16:36 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 23 Nov 2007 09:16:36 +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: e1g2000hsh.googlegroups.com; posting-host=62.95.16.58; 
	posting-account=6obM4goAAAAihX2IqW0281fEd31oVBnX
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) 
	Gecko/20070515 Firefox/2.0.0.4,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 fw.touchdown.se:8080 (squid/2.6.STABLE4)
Content-Disposition: inline
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Xref: g2news1.google.com comp.std.c++:9680

On 21 Nov, 18:54, Andrey <andrey_rya...@bk.ru> wrote:
> But the boost::tuple has these operators defined (in
> subnamespace ::tuples), look at this:http://www.boost.org/libs/tuple/doc/tuple_users_guide.html#streaming
> so the question become: Why does BGL use std::pair instead of
> boost::tuple?

Just because it is implemented doesn't mean it is a good thing.

Tuple streaming use manipulators to set the separator which means that
you need access to the stream to use them (i.e. no lexical_cast etc)

On the other hand I don't think it is possible to put the separator in
a locale in a good way.
To follow the standard you need to add the separator to e.g. ctype (or
a new facet) and then have the facets sequence_put and sequence_get.

The problem is that you can't implement do_put & do_get for sequences
since it would result in virtual template functions.
i.e.
template <typename It>
virtual sequence_put::do_put(OutIt outit, ios_base& iosbase, It begin,
It end) {
  for (; begin!=end; ++begin)
    ...
}

which of course isn't possible.

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.

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.

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



