C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Narrow Vs. wide streams

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Dave
Guest





PostPosted: Sat Jan 29, 2005 10:50 pm    Post subject: Narrow Vs. wide streams Reply with quote



The program below is conforming according to VC++ 7.1 and Comeau online. I
would have expected a type mismatch. Am I seeing a compiler problem, or is
the observed behavior correct?

Thanks!


#include <iostream>

using namespace std;

int main()
{
// Displays a hex number under VC++ 7.1
cout << L"Hello world!" << endl;

// Displays "Hello world!" under VC++ 7.1
wcout << "Hello world!" << endl;
}


Back to top
Jonathan Turkanis
Guest





PostPosted: Sat Jan 29, 2005 11:57 pm    Post subject: Re: Narrow Vs. wide streams Reply with quote



Efrat Regev wrote:
Quote:
"Dave" <better_cs_now (AT) yahoo (DOT) com> wrote in message
news:10vo4ojqm9gsvbf (AT) news (DOT) supernews.com...
The program below is conforming according to VC++ 7.1 and Comeau
online. I would have expected a type mismatch. Am I seeing a
compiler problem, or is the observed behavior correct?

Thanks!


#include
using namespace std;

int main()
{
// Displays a hex number under VC++ 7.1
cout << L"Hello world!" << endl;

// Displays "Hello world!" under VC++ 7.1
wcout << "Hello world!" << endl;
}



Your operator<< call calls a method of the form

Imp &operator<<(const void *p_val)

in both cases.

In the first case only: narrow C-style strings can be written to any
basic_ostream: chars are widened using a ctype facet.

Quote:
The subsequent "translation" from void * to char * or
w_char * is handled by the stream, and is independent from
what p_val originally pointed to (as far as I understand).

Jonathan



Back to top
Efrat Regev
Guest





PostPosted: Sun Jan 30, 2005 12:46 am    Post subject: Re: Narrow Vs. wide streams Reply with quote



"Dave" <better_cs_now (AT) yahoo (DOT) com> wrote

Quote:
The program below is conforming according to VC++ 7.1 and Comeau online.
I
would have expected a type mismatch. Am I seeing a compiler problem, or
is
the observed behavior correct?

Thanks!


#include
using namespace std;

int main()
{
// Displays a hex number under VC++ 7.1
cout << L"Hello world!" << endl;

// Displays "Hello world!" under VC++ 7.1
wcout << "Hello world!" << endl;
}



Your operator<< call calls a method of the form

Imp &operator<<(const void *p_val)

in both cases. The subsequent "translation" from void * to char * or w_char
* is handled by the stream, and is independent from
what p_val originally pointed to (as far as I understand).



Back to top
Efrat Regev
Guest





PostPosted: Sun Jan 30, 2005 3:19 am    Post subject: Re: Narrow Vs. wide streams Reply with quote

"Jonathan Turkanis" <technews (AT) kangaroologic (DOT) com> wrote

Quote:
Efrat Regev wrote:
"Dave" <better_cs_now (AT) yahoo (DOT) com> wrote in message
news:10vo4ojqm9gsvbf (AT) news (DOT) supernews.com...
The program below is conforming according to VC++ 7.1 and Comeau
online. I would have expected a type mismatch. Am I seeing a
compiler problem, or is the observed behavior correct?

Thanks!


#include
using namespace std;

int main()
{
// Displays a hex number under VC++ 7.1
cout << L"Hello world!" << endl;

// Displays "Hello world!" under VC++ 7.1
wcout << "Hello world!" << endl;
}



Your operator<< call calls a method of the form

Imp &operator<<(const void *p_val)

in both cases.

In the first case only: narrow C-style strings can be written to any
basic_ostream: chars are widened using a ctype facet.

The subsequent "translation" from void * to char * or
w_char * is handled by the stream, and is independent from
what p_val originally pointed to (as far as I understand).

Jonathan



Yes, you're right. Sorry for my mistaken reply.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.