| 
     
      
      
      From: Sean P. <sp...@ad...> - 2005-06-14 22:36:03
      
     
   | 
>>> >>> >>>> std::istream::int_type c_int(stream_m->get()); >>>> char c(0); >>>> >>>> c = std::use_facet<std::ctype<wchar_t> >(std::locale()).narrow >>>> (c_int, '?'); >>>> >>>> >>>> >>>> >>> >>> In the cygwin gcc that I have (gcc 3.4.4) I get the following >>> error in the above line of code: >>> >>> >>> >> >> I'm not sure where wchar_t is coming into play given that c is of >> type char. >> >> > > The reason I have to use wchar_t is because narrow's argument is of > type char_type, which in every case but the wchar_t one is just a > char, so narrow is a no-op (it would require a static_cast to fit > the parameter to the argument, at which point narrow is moot). > I understand - this is simply some confusion about how istream::get() works - It returns either a character c or traits::eof() - the reason it returns an int_type is because traits::eof is always out-of-band for the character type (int_type is always larger than char_type). To recover the character use traits::to_char_type(). Sean > > > >> >> >> >>> >>> >>> >>> >>> >>>> Exception: St8bad_cast >>>> >>>> >>>> >>>> >>> >>> Has anyone seen this before? Any ideas of a possible workaround? >>> Anyone know of an easier (yet equally portable) means of >>> narrowing an int_type value from a stream::get()? >>> >>> >>> >> >> char c (stream_m->narrow(c_int, '?')); >> >> > > See above. > > > >> Sean >> >> >> >> >> >>> >>> Blessings, >>> Foster >>> >>> -- >>> Foster T. Brereton <}}}>< Romans 3:21-26 >>> A d o b e S o f t w a r e T e c h n o l o g y L a b >>> "What 99 percent of programmers need to know is not how to build >>> components but how to use them." -- Alexander Stepanov >>> >>> >>> >>> ------------------------------------------------------- >>> SF.Net email is sponsored by: Discover Easy Linux Migration >>> Strategies >>> from IBM. Find simple to follow Roadmaps, straightforward articles, >>> informative Webcasts and more! Get everything you need to get up to >>> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click >>> _______________________________________________ >>> Adobe-source-devel mailing list >>> Ado...@li... >>> https://lists.sourceforge.net/lists/listinfo/adobe-source-devel >>> >>> >>> >>> >> >> >> >> >> > -- > Foster T. Brereton <}}}>< Romans 3:21-26 > A d o b e S o f t w a r e T e c h n o l o g y L a b > "What 99 percent of programmers need to know is not how to build > components but how to use them." -- Alexander Stepanov > > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > Adobe-source-devel mailing list > Ado...@li... > https://lists.sourceforge.net/lists/listinfo/adobe-source-devel > >  |