Thu Sep 21 08:15:29 2017
EVENTS
 FREE
SOFTWARE
INSTITUTE

POLITICS
JOBS
MEMBERS'
CORNER

MAILING
LIST

NYLXS Mailing Lists and Archives
NYLXS Members have a lot to say and share but we don't keep many secrets. Join the Hangout Mailing List and say your peice.

DATE 2011-07-01

HANGOUT

2017-09-21 | 2017-08-21 | 2017-07-21 | 2017-06-21 | 2017-05-21 | 2017-04-21 | 2017-03-21 | 2017-02-21 | 2017-01-21 | 2016-12-21 | 2016-11-21 | 2016-10-21 | 2016-09-21 | 2016-08-21 | 2016-07-21 | 2016-06-21 | 2016-05-21 | 2016-04-21 | 2016-03-21 | 2016-02-21 | 2016-01-21 | 2015-12-21 | 2015-11-21 | 2015-10-21 | 2015-09-21 | 2015-08-21 | 2015-07-21 | 2015-06-21 | 2015-05-21 | 2015-04-21 | 2015-03-21 | 2015-02-21 | 2015-01-21 | 2014-12-21 | 2014-11-21 | 2014-10-21 | 2014-09-21 | 2014-08-21 | 2014-07-21 | 2014-06-21 | 2014-05-21 | 2014-04-21 | 2014-03-21 | 2014-02-21 | 2014-01-21 | 2013-12-21 | 2013-11-21 | 2013-10-21 | 2013-09-21 | 2013-08-21 | 2013-07-21 | 2013-06-21 | 2013-05-21 | 2013-04-21 | 2013-03-21 | 2013-02-21 | 2013-01-21 | 2012-12-21 | 2012-11-21 | 2012-10-21 | 2012-09-21 | 2012-08-21 | 2012-07-21 | 2012-06-21 | 2012-05-21 | 2012-04-21 | 2012-03-21 | 2012-02-21 | 2012-01-21 | 2011-12-21 | 2011-11-21 | 2011-10-21 | 2011-09-21 | 2011-08-21 | 2011-07-21 | 2011-06-21 | 2011-05-21 | 2011-04-21 | 2011-03-21 | 2011-02-21 | 2011-01-21 | 2010-12-21 | 2010-11-21 | 2010-10-21 | 2010-09-21 | 2010-08-21 | 2010-07-21 | 2010-06-21 | 2010-05-21 | 2010-04-21 | 2010-03-21 | 2010-02-21 | 2010-01-21 | 2009-12-21 | 2009-11-21 | 2009-10-21 | 2009-09-21 | 2009-08-21 | 2009-07-21 | 2009-06-21 | 2009-05-21 | 2009-04-21 | 2009-03-21 | 2009-02-21 | 2009-01-21 | 2008-12-21 | 2008-11-21 | 2008-10-21 | 2008-09-21 | 2008-08-21 | 2008-07-21 | 2008-06-21 | 2008-05-21 | 2008-04-21 | 2008-03-21 | 2008-02-21 | 2008-01-21 | 2007-12-21 | 2007-11-21 | 2007-10-21 | 2007-09-21 | 2007-08-21 | 2007-07-21 | 2007-06-21 | 2007-05-21 | 2007-04-21 | 2007-03-21 | 2007-02-21 | 2007-01-21 | 2006-12-21 | 2006-11-21 | 2006-10-21 | 2006-09-21 | 2006-08-21 | 2006-07-21 | 2006-06-21 | 2006-05-21 | 2006-04-21 | 2006-03-21 | 2006-02-21 | 2006-01-21 | 2005-12-21 | 2005-11-21 | 2005-10-21 | 2005-09-21 | 2005-08-21 | 2005-07-21 | 2005-06-21 | 2005-05-21 | 2005-04-21 | 2005-03-21 | 2005-02-21 | 2005-01-21 | 2004-12-21 | 2004-11-21 | 2004-10-21 | 2004-09-21 | 2004-08-21 | 2004-07-21 | 2004-06-21 | 2004-05-21 | 2004-04-21 | 2004-03-21 | 2004-02-21 | 2004-01-21 | 2003-12-21 | 2003-11-21 | 2003-10-21 | 2003-09-21 | 2003-08-21 | 2003-07-21 | 2003-06-21 | 2003-05-21 | 2003-04-21 | 2003-03-21 | 2003-02-21 | 2003-01-21 | 2002-12-21 | 2002-11-21 | 2002-10-21 | 2002-09-21 | 2002-08-21 | 2002-07-21 | 2002-06-21 | 2002-05-21 | 2002-04-21 | 2002-03-21 | 2002-02-21 | 2002-01-21 | 2001-12-21 | 2001-11-21 | 2001-10-21 | 2001-09-21 | 2001-08-21 | 2001-07-21 | 2001-06-21 | 2001-05-21 | 2001-04-21 | 2001-03-21 | 2001-02-21 | 2001-01-21 | 2000-12-21 | 2000-11-21 | 2000-10-21 | 2000-09-21 | 2000-08-21 | 2000-07-21 | 2000-06-21 | 2000-05-21 | 2000-04-21 | 2000-03-21 | 2000-02-21 | 2000-01-21 | 1999-12-21

Key: archive Value: 2011-07-01

Key: id Value: 540633

MESSAGE
DATE 2011-07-07
FROM Ruben Safir
SUBJECT Subject: [NYLXS - HANGOUT] (fwd) Re: iostream manipulator construction and design
From owner-hangout-outgoing-at-mrbrklyn.com Thu Jul 7 02:06:54 2011
Return-Path:
X-Original-To: archive-at-mrbrklyn.com
Delivered-To: archive-at-mrbrklyn.com
Received: by www2.mrbrklyn.com (Postfix)
id 2CBE33A748; Thu, 7 Jul 2011 02:06:54 -0400 (EDT)
Delivered-To: hangout-outgoing-at-www2.mrbrklyn.com
Received: by www2.mrbrklyn.com (Postfix, from userid 28)
id 1BB6B3A7EF; Thu, 7 Jul 2011 02:06:54 -0400 (EDT)
Delivered-To: hangout-at-nylxs.com
Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89])
by www2.mrbrklyn.com (Postfix) with ESMTP id CA77A3A748
for ; Thu, 7 Jul 2011 02:06:53 -0400 (EDT)
Received: from panix2.panix.com (panix2.panix.com [166.84.1.2])
by mailbackend.panix.com (Postfix) with ESMTP id BB4AA33F10
for ; Thu, 7 Jul 2011 02:06:53 -0400 (EDT)
Received: by panix2.panix.com (Postfix, from userid 20529)
id 839C733C4A; Thu, 7 Jul 2011 02:06:53 -0400 (EDT)
From: Ruben Safir
To: hangout-at-nylxs.com
Subject: [NYLXS - HANGOUT] (fwd) Re: iostream manipulator construction and design
User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (NetBSD/5.1 (i386))
Message-Id: <20110707060653.839C733C4A-at-panix2.panix.com>
Date: Thu, 7 Jul 2011 02:06:53 -0400 (EDT)
Sender: owner-hangout-at-mrbrklyn.com
Precedence: bulk
Reply-To: hangout-at-mrbrklyn.com

-- forwarded message --
Path: reader1.panix.com!panix!usenet.stanford.edu!postnews.google.com!j28g2000vbp.googlegroups.com!not-for-mail
From: Michael DOUBEZ
Newsgroups: comp.lang.c++
Subject: Re: iostream manipulator construction and design
Date: Wed, 6 Jul 2011 01:00:41 -0700 (PDT)
Organization: http://groups.google.com
Lines: 116
Message-ID: <37a44930-d9e1-4c9b-b06d-fc0204ae23a7-at-j28g2000vbp.googlegroups.com>
References:
NNTP-Posting-Host: 62.160.54.163
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1309939340 12470 127.0.0.1 (6 Jul 2011 08:02:20 GMT)
X-Complaints-To: groups-abuse-at-google.com
NNTP-Posting-Date: Wed, 6 Jul 2011 08:02:20 +0000 (UTC)
Complaints-To: groups-abuse-at-google.com
Injection-Info: j28g2000vbp.googlegroups.com; posting-host=62.160.54.163; posting-account=4_dwSAoAAAD_OEYz89wEMQOvnJlm6isC
User-Agent: G2/1.0
X-Google-Web-Client: true
X-Google-Header-Order: HUALESRCNK
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0,gzip(gfe)
Xref: panix comp.lang.c++:1087311

On Jul 6, 4:55=A0am, Ruben Safir wrote:
> I've covered the iostream operations in Stroustrup but there is a section
> that I'm failing to understand in section 21.4.6.1 (of the third edition
> of C++ - The Programming Language) which I hope that someone can help
> me decipher. =A0The section discusses Manipultors that take arguments and
> Stroustrup states
>
>
> "Manipulators that take arguments can also be useful. =A0For example, we
> might want to write
>
> =A0 =A0cout << setprecision(4) << angle;
>
> to print the value of the floating-point variable angle with four
> digits.
>
> To do this, setprecision must return an object that is initialized by 4
> and that calls cout::setprcision when involked. =A0Such a manipulator is =
a
> function object thatr is involed by << rather than by (). =A0The exact
> tyoe of function object is implementation-defined, but it might be
> defined like this:
>
> =A0 =A0struct smanip{
> =A0 =A0 =A0 ios_base& (*f)(ios_base&, int); //function to be called
> =A0 =A0 =A0 int i;
>
> =A0 =A0 =A0 smanip(ios_base& (*ff) (ios_base&, int), int ii) : f(ff, i(ii=
){}
> =A0 =A0};
>
> =A0 =A0template
> =A0 =A0ostream& operator<<(ostream& os, smanip& m)
> =A0 =A0{
> =A0 =A0 =A0 return m.f(os, m.i);
> =A0 =A0}
>
> The smanip constructor stores its arguments in f and i and the
> operator<< calls f(i). =A0We can now define setprecision() like this:
>
> =A0 =A0ios_base& set_precision(ios)base& s, int n) =A0//helper
> =A0 =A0{
> =A0 =A0 =A0 return s.setprecision(n); //call member function
> =A0 =A0}
>
> =A0 =A0inline smap setprecision(int n)
> =A0 =A0{
> =A0 =A0 =A0 =A0 =A0return smanip(set_precision, n);
> =A0 =A0}
>
> We can now write:
> =A0 =A0cout << setprecision(4) << angle;
> " =A0
>

>
> What don't understand a couple of things here, and this might be an
> accumulation of increasing confusion on my part as I've continued
> through this chapter.
>
> First, I just don't understand what the problem is that is being solved.

The problem being solved is being able to use a parametrized modifier
with the same syntax.
By example, if you want to uppercase your output, you write:
out<
This works because ostream (in fact basic_ostream<>) defines an
overload like

basic_ostream<>& operator<<(ios_base& (*pf)(ios_base&))
{
*pt(*this);
return *this;
}

And std::uppercase simply set the relevant flag
ios_base& std::uppercase(ios_base& os)
{
os.setf(ios_base::uppercase);
return os;
}


> Why can't a manipulator just take an argument of an int and return a
> base_stream object, like the manipulators that don't take an argument?

But now, if you want a parameter to uppercase:
ios_base& set_uppercase(ios_base& os, int isUppercase)
{
if(isUppercase)os.setf(ios_base::uppercase);
else os.unsetf(ios_base::uppercase);
return os;
}

You cannot directly use set_uppercase because, there is no matching
overload in ostream. C++ provides a magic implementation specific
class called smanip which provide a mechanism for calling your
function.

smanip setUppercase(bool b)
{
return smanip(set_uppercase, b);
}

> Secondly, the exqmple completely befuddles me. =A0I'm guessing that don't
> understand the order of operations of
>
> =A0 =A0cout << setprecision(4) << angle;
>
> =A0 =A0is ostream<< called first and then the function setprecision?

No, it can help if you rewrite it with function call:
operator<<( operator<<(cout ,setprecision(4)) , angle );

--
Michael
-- end of forwarded message --

  1. 2011-07-01 Ron Guerin <ron-at-vnetworx.net> Re: [NYLXS - HANGOUT] (fwd) US-NY: Brooklyn-Sr Pipeline Corrosion
  2. 2011-07-01 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] (fwd) US-NY: Brooklyn-Sr Pipeline Corrosion
  3. 2011-07-01 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] (fwd) US-NY: Brooklyn-Sr Pipeline Corrosion
  4. 2011-07-02 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] [ruben-at-mrbrklyn.com: Re: Fwd: Baruch Dayan HaEmes]
  5. 2011-07-02 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] HP Toouchpad is out
  6. 2011-07-03 From: "Paul Robert Marino" <prmarino1-at-gmail.com> Re: [NYLXS - HANGOUT] HP Toouchpad is out
  7. 2011-07-03 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] HP Toouchpad is out
  8. 2011-07-04 Paul Robert Marino <prmarino1-at-gmail.com> Re: [NYLXS - HANGOUT] HP Toouchpad is out
  9. 2011-07-05 swd <sderrick-at-optonline.net> Subject: [NYLXS - HANGOUT] "Cottage cheese sales plummet as Israeli consumers revolt over price"
  10. 2011-07-05 Ron Guerin <ron-at-vnetworx.net> Subject: [NYLXS - HANGOUT] NYLUG Workshop / Hacking Society (Smalltalk, C++, Python) Tuesday July 5 6:00PM-8:00PM
  11. 2011-07-05 Contrarian <adrba-at-nyct.net> Re: [NYLXS - HANGOUT] "Cottage cheese sales plummet as Israeli
  12. 2011-07-05 Elfen Magix <elfen_magix-at-yahoo.com> Subject: [NYLXS - HANGOUT] Death of Mom.
  13. 2011-07-05 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] Death of Mom.
  14. 2011-07-05 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) iostream manipulator construction and design
  15. 2011-07-05 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) array initiation - methodology for converting C code to C++
  16. 2011-07-05 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] [samantha-at-10gen.com: [New-York-C-Developers-Group] Next Meetup -
  17. 2011-07-05 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] [samantha-at-10gen.com: [New-York-C-Developers-Group] Next Meetup -
  18. 2011-07-05 Ron Guerin <ron-at-vnetworx.net> Re: [NYLXS - HANGOUT] Death of Mom.
  19. 2011-07-05 Ron Guerin <ron-at-vnetworx.net> Re: [NYLXS - HANGOUT] "Cottage cheese sales plummet as Israeli consumers
  20. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] [rick-at-linuxmafia.com: [conspire] (forw) Re:
  21. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] OpenSuse 11.4
  22. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) Re: iostream manipulator construction and design
  23. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) iostream manipulator construction and design
  24. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) Re: iostream manipulator construction and design
  25. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) Re: iostream manipulator construction and design
  26. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) Re: iostream manipulator construction and design
  27. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) Re: iostream manipulator construction and design
  28. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) Re: iostream manipulator construction and design
  29. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) array initiation - methodology for converting C code to C++
  30. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) Re: array initiation - methodology for converting C code to C++
  31. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) Re: array initiation - methodology for converting C code to C++
  32. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) Re: array initiation - methodology for converting C code to C++
  33. 2011-07-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] (fwd) Online C++ test
  34. 2011-07-08 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Quick before shabbos - please read
  35. 2011-07-13 einker <eminker-at-gmail.com> Subject: [NYLXS - HANGOUT] Fwd: Linux Engineer needed!
  36. 2011-07-14 Ron Guerin <ron-at-vnetworx.net> Subject: [NYLXS - HANGOUT] NYLUG Presents: 7/24 -at- 12:00PM NYLUG on The NYLUG Summer Barbecue!
  37. 2011-07-17 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Death in the family
  38. 2011-07-17 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] NYC DoE
  39. 2011-07-17 Elfen Magix <elfen_magix-at-yahoo.com> Re: [NYLXS - HANGOUT] NYC DoE
  40. 2011-07-17 Elfen Magix <elfen_magix-at-yahoo.com> Re: [NYLXS - HANGOUT] Death in the family
  41. 2011-07-17 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] Death in the family
  42. 2011-07-17 Kevin Mark <kevin.mark-at-verizon.net> Re: [NYLXS - HANGOUT] Death in the family
  43. 2011-07-17 Kevin Mark <kevin.mark-at-verizon.net> Re: [NYLXS - HANGOUT] Death in the family
  44. 2011-07-18 einker <eminker-at-gmail.com> Re: [NYLXS - HANGOUT] Death in the family
  45. 2011-07-18 einker <eminker-at-gmail.com> Re: [NYLXS - HANGOUT] Death in the family
  46. 2011-07-18 Robert Menes <viewtiful.icchan-at-gmail.com> Re: [NYLXS - HANGOUT] Death in the family
  47. 2011-07-18 Paul Robert Marino <prmarino1-at-gmail.com> Re: [NYLXS - HANGOUT] Death in the family
  48. 2011-07-19 Ron Guerin <ron-at-vnetworx.net> Re: [NYLXS - HANGOUT] Death in the family
  49. 2011-07-19 Contrarian <adrba-at-nyct.net> Re: [NYLXS - HANGOUT] Death in the family
  50. 2011-07-19 Ron Guerin <ron-at-vnetworx.net> Subject: [NYLXS - HANGOUT] NYLUG Workshop / Hacking Society (Smalltalk, C++, Python) Tuesday July 19 6:00PM-8:00PM
  51. 2011-07-21 George Cluny <ceo.brooklyn-at-gmail.com> Subject: [NYLXS - HANGOUT] Join me on AIM!

NYLXS are Do'ers and the first step of Doing is Joining! Join NYLXS and make a difference in your community today!