Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #7561

Re: iostream manipulator construction and design

From Ruben Safir <ruben@mrbrklyn.com>
Newsgroups comp.lang.c++
Subject Re: iostream manipulator construction and design
Date 2011-07-07 02:51 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <iv36vv$j8s$1@reader1.panix.com> (permalink)
References <iv0iqd$alg$1@reader1.panix.com> <iv1tcj$mbj$2@reader1.panix.com> <iv24u2$pbf$1@dont-email.me>

Show all headers | View raw


On Wed, 06 Jul 2011 19:13:22 +0200, Alf P. Steinbach /Usenet wrote:


>    std::ostream& operator<<(
>        std::ostream&           stream,
>        MyWidthManip const&     m
>        )
>    {
>        stream.setw( m.w_ );    // I'm just assuming there is a setw.
>        Dunno. return stream;
>    }
> 
> And that's it.
> 
> For a manipulator without arguments you don't need a supporting class,
> because the manipulator can just be a function that << operator then
> calls.

what is wrong with 

std::ostream& operator<<(std::ostread& os, flags (*f)(int a)) {
	os.setf(f(a));
}

flags  setw(x){
	return std::ios_base:setw(x);
}

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

iostream manipulator construction and design Ruben Safir <ruben@mrbrklyn.com> - 2011-07-06 02:55 +0000
  Re: iostream manipulator construction and design Michael DOUBEZ <michael.doubez@free.fr> - 2011-07-06 01:00 -0700
  Re: iostream manipulator construction and design Ruben Safir <ruben@mrbrklyn.com> - 2011-07-06 15:01 +0000
    Re: iostream manipulator construction and design "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-07-06 19:13 +0200
      Re: iostream manipulator construction and design Ruben Safir <ruben@mrbrklyn.com> - 2011-07-06 18:00 +0000
      Re: iostream manipulator construction and design Ruben Safir <ruben@mrbrklyn.com> - 2011-07-07 02:51 +0000
        Re: iostream manipulator construction and design "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-07-07 11:13 +0200

csiph-web