showpos modifier and unsigned integers
Jonathan Wakely
cow@compsoc.man.ac.uk
Wed Dec 22 09:49:00 GMT 2004
On Wed, Dec 22, 2004 at 08:05:00AM +0100, Dirk Jagdmann wrote:
> Hello,
>
> I'm not sure if the followin is the correct and intended output
> (according to standard). Given this simple program:
>
> #include <iostream>
> int main()
> {
> std::cout << std::showpos
> << (unsigned)+1 << std::endl
> << (signed)+1 << std::endl;
> return 0;
> }
>
> The output is:
> 1
> +1
>
> I've ran this with g++ 3.4.2 on x86. For unsigned integers the showpos
> modifier is ignored. But as unsigned integers are always positive
> integers I'd like to see them prefixed with '+'.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15565
> Now I wonder: is g++ behaviour correct, thus does the standard say,
> that for unsigned ints nothing is prefixed?
jon
--
"Reason and free inquiry are the effectual agents against error.
They are the natural enemies of error and error only."
- Thomas Jefferson
More information about the Libstdc++
mailing list