<paul.wilkins@gmail.com> wrote in message
news:1105991110.684526.216760@f14g2000cwb.googlegr oups.com...[color=blue]
> Hi,
>
> I have a function I have written that works with g++ 2.95.3 that I
> would like to use with newer g++ compilers >= 3.2.0. The function is a
> stream manipulator similar to setw(). The code does not compile with
> newer versions of g++.[/color]
"does not compile" gives no useful information for us
to help you. However, what you've posted below is
not standard C++, which is what we discuss here.
[color=blue]
> Please help me port this code.
>
> Thanks,
> -Paul
>
>
> #include <iostream.h>
> #include <iomanip.h>[/color]
Neither of these headers are, or ever have been part of
standard C++. The corresponding standard headers are
<iostream> and <iomanip> (none of the standard headers
have ".h" in their names. All of the library names
(except macros) are defined in namespace 'std'.
[color=blue]
>
> int x = 1;
> ios&[/color]
The standard type 'ios' has the full name 'std::ios',
(which is actually a specialization of the template
'std::basic_ios'), and is declared by header <ios>.
[color=blue]
> temp_setw(ios & o, int n) { if(x) o.width(n); return o; }
> smanip<int> my_setw(int n) { return smanip<int> (temp_setw,n); }[/color]
There is no standard type 'smanip', nor have you provide
a definition of one.
[color=blue]
>
> int main(int argc,char *argv[]) {
> int a = 234;
> x = 1; cout << a << my_setw(11) << "test" << endl;
> x = 0; cout << a << my_setw(11) << "test" << endl;
> }[/color]
Book suggestions:
www.josuttis.com/libbook http://www.langer.camelot.de/iostreams.html
-Mike