home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,080 of 33,346   
   Timothy Madden to All   
   ios manipulator to print char/wchar_t as   
   01 Apr 12 01:08:21   
   
   From: terminatorul@gmail.com   
      
   Hello   
      
   Shoudn't there be an ios manipulator that prints the next charT   
   (char/wchar_t/...) as the number ? Similar to the way boolalpha prints   
   the next bool with a different format.   
      
   I have run into this when using a template with an integral argument   
   (the channel type for color values for image pixels), and much to my   
   surprize if the type is int I see a number in the console, if it is   
   unsigned char I see nothing...   
      
   Simply casting the value to (int) or other integral type is not enough   
   since you do not know the signedness of the char type, and you do not   
   even know the underlaying integral type for the given charT (an   
   implementation is free to use long long to represent wchar_t ...)   
      
   I ended up using   
   	cout << (channel_value + 0)   
   but in a template I think this is still not generic enough, since it   
   introduces requirements on the type for channel_value, which are not   
   there with a simple   
   	cout  << channel_value   
   Also I am not sure of the result type when wchar_t is int or unsigned,   
   and I have (wchar_value + 0)   
      
   Thank you,   
   Timothy Madden   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca