Friday, February 13, 2015

Digest for comp.lang.c++@googlegroups.com - 14 updates in 4 topics

"Norman J. Goldstein" <normvcr@telus.net>: Feb 12 09:43PM -0800

Here is code that does not compile with
gcc version 4.8.3 20140911 (Red Hat 4.8.3-7) (GCC)
 
#include <iostream>
using namespace std;
 
istream& operator>>( istream&, const char* );// Line A
 
namespace
{
class Foo {};
void operator>>( Foo, Foo ); // Line B
 
void copy( void )
{
const char* memb = "bad";
cin >> memb;
}
}
 
Here are two ways to make it compile:
1. Move Line A into the namespace, OR
2. Comment out Line B
 
Here is the compiler error, which I hesitate to include in the posting,
but, for completeness ...
 
bad.cpp: In function 'void {anonymous}::copy()':
bad.cpp:14:12: error: cannot bind 'std::istream
{aka std::basic_istream<char>}' lvalue to 'std::basic_istream<char>&&'
cin >> memb;
^
In file included from /usr/include/c++/4.8.3/iostream:40:0,
from bad.cpp:1:
/usr/include/c++/4.8.3/istream:872:5: error: initializing argument 1
of 'std::basic_istream<_CharT, _Traits>&
std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) [with
_CharT = char; _Traits = std::char_traits<char>; _Tp = const char*]'
operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
^
"Öö Tiib" <ootiib@hot.ee>: Feb 13 12:18AM -0800

On Friday, 13 February 2015 07:43:58 UTC+2, Norman J. Goldstein wrote:
> _CharT = char; _Traits = std::char_traits<char>; _Tp = const char*]'
> operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
> ^
 
It feels the behaviour of compiler is conforming.
It finds 'operator>>( Foo, Foo )' with ordinary lookup and that stops
it from looking into enclosing global namespace of anonymous namespace.
If you comment it out it will look into global namespace too with
ordinary lookup. Also if you move the 'operator>>( istream&, const char*)'
to anonymous then it finds both. With ADL it finds only the operators
in namespace 'std'.
 
It is considered impractical to declare operators that operate on standard
and fundamental types only in global or user-defined namespaces. It will
often cause issues like you describe.
Paavo Helde <myfirstname@osa.pri.ee>: Feb 13 07:17AM -0600

"Norman J. Goldstein" <normvcr@telus.net> wrote in
 
> Here are two ways to make it compile:
> 1. Move Line A into the namespace, OR
> 2. Comment out Line B
 
Yes, this is name lookup problem as described by 嘱 Tiib. To force a
particular overloaded function, spell out the correct name explicitly:
 
void copy( void )
{
const char* memb = "bad";
::operator>>(cin, memb);
}
"Norman J. Goldstein" <normvcr@telus.net>: Feb 13 06:55AM -0800

On 02/13/2015 05:17 AM, Paavo Helde wrote:
> const char* memb = "bad";
> ::operator>>(cin, memb);
> }
 
Thank you, both. Based on what you said, I "fixed" this by defining the
same operator in the namespace:
 
namespace
{
istream& operator>>( istream& is, const char* ccp ) {
return ::operator>>( is, ccp ); }
}
 
The funny thing is, I've been using the global
operator>>( istream&,const char*) ) for years, and it only now posed
this problem.
Paavo Helde <myfirstname@osa.pri.ee>: Feb 13 08:59AM -0600

"Norman J. Goldstein" <normvcr@telus.net> wrote in news:mbl394$3ue$1
> istream& operator>>( istream& is, const char* ccp ) {
> return ::operator>>( is, ccp ); }
> }
 
This can be done easier by:
 
namespace
{
using ::operator>>;
}
"Norman J. Goldstein" <normvcr@telus.net>: Feb 13 09:52AM -0800

On 02/13/2015 06:59 AM, Paavo Helde wrote:
>> same operator in the namespace:
 
>> namespace
>> {
inline
> {
> using ::operator>>;
> }
 
OK. I will use the "using", although it pulls in all the operator>>
methods, not just the one with the given signature. But, that is
probably what I want, anyway!
jt@toerring.de (Jens Thoms Toerring): Feb 13 07:42PM

> The funny thing is, I've been using the global
> operator>>( istream&,const char*) ) for years, and it only now posed
> this problem.
 
Apologies for my ignorance, but how can you use an istream
on a 'const char *'? My understanding has been that you
need a reference or a pointer to something non-constant.
Otherwise, how is the stream supposed to write to it (in
your example program even to a string literal, which may
reside in read-only memory)?
 
Best regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
DSF <notavalid@address.here>: Feb 13 02:39PM -0500

Hello!
 
Even though I find most M$ software counterintuitive, I am looking
at M$ Visual Studio Community 2013. If anyone here has had experience
with it, I'd like to pose these questions. (Neither are subjective.)
 
M$ claims it is identical to their Visual Studio 2013 Pro, as
compared with Visual Studio Express which is lacking several
components of the Pro version. The only difference is licensing. Can
you confirm this?
 
The "Community" part of the title has me to wonder if this software
is facilitated entirely within your computer or is somewhat
"Cloud-based." Does it require an Internet connection to use?
 
What with Adobe going to a %100 "pay as you go" business model, it's
got me to wondering. (Although I don't believe I've read whether
Adobe's model is actually Internet-based software or local
computer-based software that stops working if you stop paying.) I do
believe you need an active Internet connection during use.
 
Thanks for any info,
DSF
"'Later' is the beginning of what's not to be."
D.S. Fiscus
DSF <notavalid@address.here>: Feb 13 02:09PM -0500

Pardon this test.
 
But I posted a message yesterday that has not shown up.
"'Later' is the beginning of what's not to be."
D.S. Fiscus
DSF <notavalid@address.here>: Feb 13 02:11PM -0500

Sigh! Nevermind. I had my newsreader set to show kept messages
only!
 
DSF
drew@furrfu.invalid (Drew Lawson): Feb 13 04:12AM

In article <mbiosu$it0$1@dont-email.me>
>> of that.
 
>Ok, please let's all stop any discussion we had going on and concentrate
>on Drew's distaste for Microsoft dropping support for XP.
 
Again, you have profound problems in understanding threaded discussions.
 
>Sorry, Drew, I cannot defend Microsoft for you,
 
Not looking for a defense of Microsoft. You claimed that "no one"
would do [foo], while several people pointed out that MS exactly
did [foo].
 
A couple years ago, I mentally filed you as a clueless git who
claimed understanding that was clearly not obtained. You have just
helped confirm that I was correct.
 
You also apparently do not understand the difference between a
"thread" and a "sub-thread", which (like many of the things that
give you trouble) has only been established for 20-30 years.
 
I will return to reading you about how I read woodbrian -- permanent
freshman who is sure he knows the Real Truth.
 
Oh, and for Brian, I don't give a god damned fucking cunt squat
what you wish to say about the wording that I choose. As an expressed
Christian, it is your obligation to forgive and accept.
 
Or be an ass sucking hypocrite.
 
--
Drew Lawson While they all shake hands
and draw their lines in the sand
and forget about the mess they've made
Ian Collins <ian-news@hotmail.com>: Feb 13 06:02PM +1300

Christopher Pisz wrote:
>> be web based.
 
> But you have to get information from the web to your application.
> Something somewhere is communicating.
 
Eh? All the app has to do is handle message requests form a basic CGI app.
 
 
> Well, even the fact that you'd have to link with Winsock or ...I dunno
> what others use...posix sockets?...boost?.. requires a bunch of compiler
> options, make files, msbuild, ant, or something.
 
All non-trivial applications have to link something! As long as the
interfaces are common, who cares?
 
--
Ian Collins
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Feb 13 04:38PM

On 13/02/2015 04:12, Drew Lawson wrote:
> what you wish to say about the wording that I choose. As an expressed
> Christian, it is your obligation to forgive and accept.
 
> Or be an ass sucking hypocrite.
 
Sausages.
 
/Flibble
Christopher Pisz <nospam@notanaddress.com>: Feb 13 10:45AM -0600

On 2/12/2015 10:12 PM, Drew Lawson wrote:
 
> Not looking for a defense of Microsoft. You claimed that "no one"
> would do [foo], while several people pointed out that MS exactly
> did [foo].
 
Microsoft, a multi-billion dollar, semi-monopoly, dropped support for a
_version_ of their flagship software.
 
I don't know what claim you are referring to. I don't remember typing
"no one" and I have no idea which [foo] you have conjured up.
 
> what you wish to say about the wording that I choose. As an expressed
> Christian, it is your obligation to forgive and accept.
 
> Or be an ass sucking hypocrite.
 
So angry. Therapy might help.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: