On Jul 10, 12:47 pm, Steven Woody <narkewo...@gmail.comwrote:
Here is the code,
uint16_t n1, n2;
...
std::ostringstream os;
os << "(" << std::hex << std::setw(4) << std::setfill('0')
<< n1 << "," << std::setw(4) << std::setfill('0')
<< n2 << ")";
You see, I have to used setw,setfill twice for print two
integer. This is the only we I found works. Is there a
simple representaion to archive same purpose?
os << '(' << HexFmt( 4 ) << n1 << ',' << HexFmt( 4 ) << n2 <<
')' ;
More generally, the standard manipulators (except maybe for
setw) are really only there to serve as examples. You wouldn't
normally use them in real code; you'd define application
specific manipulators, like HexFmt above. (My implementation of
HexFmt is available at my site, but more generally, you'll want
to provide your own, since only you know what logical markup is
applicable to your application.)
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34