By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,445 Members | 1,329 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,445 IT Pros & Developers. It's quick & easy.

argument dependent lookup

P: n/a
simple program:

#include <iostream>
int main() {
std::cout << "bleee" << endl;
}

both VC++.NET 2003 and GCC (3.3 i think) tell me that endl is an undefined
identivier. is that correct, or should endl be visible through ADL?

thanks,
martin
Oct 25 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
* Martin Vorbrodt:
simple program:

#include <iostream>
int main() {
std::cout << "bleee" << endl;
}

both VC++.NET 2003 and GCC (3.3 i think) tell me that endl is an undefined
identivier. is that correct, or should endl be visible through ADL?


Interesting, and I don't know.

Datum: fails to compile also with Comeau online, also with <ostream> included.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Oct 25 '05 #2

P: n/a

Martin Vorbrodt wrote:
simple program:

#include <iostream>
int main() {
std::cout << "bleee" << endl;
}

both VC++.NET 2003 and GCC (3.3 i think) tell me that endl is an undefined
identivier. is that correct, or should endl be visible through ADL?

thanks,
martin


I'm pretty sure that is correct. The overloaded operator call in the
case of endl is a member function, so ADL shouldn't apply.

Oct 25 '05 #3

P: n/a

"Martin Vorbrodt" <mv*******@poczta.onet.pl> wrote in message
news:dj**********@news.onet.pl...
simple program:

#include <iostream>
int main() {
std::cout << "bleee" << endl;
}

both VC++.NET 2003 and GCC (3.3 i think) tell me that endl is an undefined
identivier. is that correct, or should endl be visible through ADL?

thanks,
martin


When you write std:: in front of cout, what could you possibly be missing in
front of endl?

;o)

You could of course bring in the whole namespace instead by doing a

using namespace std;

at the top.

Best regards,
Mogens
Oct 25 '05 #4

P: n/a
aha, so maybe i'll write std:: in front of the << operator too?
std::operator<<(cout, "bleee");

that's not the point. operator << is not prequalified with std:: yet it is
visible in the expression. so i wonder why endl isn't.

"Mogens Heller Jensen" <mo****@mookid.dk> wrote in message
news:43**********************@nntp02.dk.telia.net. ..

"Martin Vorbrodt" <mv*******@poczta.onet.pl> wrote in message
news:dj**********@news.onet.pl...
simple program:

#include <iostream>
int main() {
std::cout << "bleee" << endl;
}

both VC++.NET 2003 and GCC (3.3 i think) tell me that endl is an undefined identivier. is that correct, or should endl be visible through ADL?

thanks,
martin
When you write std:: in front of cout, what could you possibly be missing

in front of endl?

;o)

You could of course bring in the whole namespace instead by doing a

using namespace std;

at the top.

Best regards,
Mogens

Oct 25 '05 #5

P: n/a
* Alf P. Steinbach:
* Martin Vorbrodt:
simple program:

#include <iostream>
int main() {
std::cout << "bleee" << endl;
}

both VC++.NET 2003 and GCC (3.3 i think) tell me that endl is an undefined
identivier. is that correct, or should endl be visible through ADL?


Interesting, and I don't know.

Datum: fails to compile also with Comeau online, also with <ostream> included.


Bang. "<<" is a call. "endl" is just an argument. Argument-dependent lookup
uses arguments to find functions (or operators), not opposite. QED.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Oct 25 '05 #6

P: n/a
> "Mogens Heller Jensen" <mo****@mookid.dk> wrote in message
news:43**********************@nntp02.dk.telia.net. ..

"Martin Vorbrodt" <mv*******@poczta.onet.pl> wrote in message
news:dj**********@news.onet.pl...
> simple program:
>
> #include <iostream>
> int main() {
> std::cout << "bleee" << endl;
> }
>
> both VC++.NET 2003 and GCC (3.3 i think) tell me that endl is an undefined > identivier. is that correct, or should endl be visible through ADL?
>
> thanks,
> martin
>
>
When you write std:: in front of cout, what could you possibly be missing

in
front of endl?

;o)

You could of course bring in the whole namespace instead by doing a

using namespace std;

at the top.

Best regards,
Mogens


"Martin Vorbrodt" <mv*******@poczta.onet.pl> wrote in message
news:dj**********@news.onet.pl... aha, so maybe i'll write std:: in front of the << operator too?
std::operator<<(cout, "bleee");

that's not the point. operator << is not prequalified with std:: yet it is
visible in the expression. so i wonder why endl isn't.


No, what I meant was this:
std::cout << " like this-> " << std::endl;

Operators like << are functions whose namespace and class are resolved
implicitly by the context. If you had defined a class Matrix in some
namespace called MyMath, you would automagically have the
MyMath::Matrix::operator++ called if you do this:

MyMath::Matrix m;
m++;

Otherwise the syntax would be pretty funky: m(MyMath::Matrix++); or
something :o)
Oct 25 '05 #7

P: n/a
"Alf P. Steinbach" <al***@start.no> wrote in message
news:43****************@news.individual.net...
* Alf P. Steinbach:
* Martin Vorbrodt:
simple program:

#include <iostream>
int main() {
std::cout << "bleee" << endl;
}

both VC++.NET 2003 and GCC (3.3 i think) tell me that endl is an undefined identivier. is that correct, or should endl be visible through ADL?
Interesting, and I don't know.

Datum: fails to compile also with Comeau online, also with <ostream>

included.
Bang. "<<" is a call. "endl" is just an argument. Argument-dependent lookup uses arguments to find functions (or operators), not opposite. QED.
endl is an argument, not a function. makes sense. thank you


--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Oct 25 '05 #8

P: n/a
* Martin Vorbrodt:

endl is an argument, not a function. makes sense. thank you


Uh, well, endl is also a function, but in this context it's the address of
endl that's used as an argument.

Just to be a bit less imprecise.

Hth.,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Oct 25 '05 #9

P: n/a

"Martin Vorbrodt" <mv*******@poczta.onet.pl> wrote in message
news:dj**********@news.onet.pl...
aha, so maybe i'll write std:: in front of the << operator too?
std::operator<<(cout, "bleee");

that's not the point. operator << is not prequalified with std:: yet it is
visible in the expression. so i wonder why endl isn't.


'std::endl' is only guaranteed to be declared by <ostream>

#include-ing <iostream> will indirectly declare 'std::endl'
on some implementations, but you can't depend upon it.

-Mike
Oct 25 '05 #10

P: n/a
Mike Wahler <mk******@mkwahler.net> wrote:
'std::endl' is only guaranteed to be declared by <ostream>

#include-ing <iostream> will indirectly declare 'std::endl'
on some implementations, but you can't depend upon it.


This is a perfect example of what I was thinking about in my thread
"Header file analyzer?".

--
Marcus Kwok
Oct 25 '05 #11

P: n/a
Mike Wahler wrote:

"Martin Vorbrodt" <mv*******@poczta.onet.pl> wrote in message
news:dj**********@news.onet.pl...
aha, so maybe i'll write std:: in front of the << operator too?
std::operator<<(cout, "bleee");

that's not the point. operator << is not prequalified with std::
yet it is visible in the expression. so i wonder why endl isn't.


'std::endl' is only guaranteed to be declared by <ostream>

#include-ing <iostream> will indirectly declare 'std::endl'
on some implementations, but you can't depend upon it.


That was more or less an oversight by the standard committee, no one
intended for that to be the case. In fact all the examples in the
standard (while not normative) use std::endl without including
<ostream>.

Are you aware of any implementations that require it?


Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Oct 25 '05 #12

P: n/a

"Default User" <de***********@yahoo.com> wrote in message
news:3s************@individual.net...
Mike Wahler wrote:

"Martin Vorbrodt" <mv*******@poczta.onet.pl> wrote in message
news:dj**********@news.onet.pl...
> aha, so maybe i'll write std:: in front of the << operator too?
> std::operator<<(cout, "bleee");
>
> that's not the point. operator << is not prequalified with std::
> yet it is visible in the expression. so i wonder why endl isn't.
'std::endl' is only guaranteed to be declared by <ostream>

#include-ing <iostream> will indirectly declare 'std::endl'
on some implementations, but you can't depend upon it.


That was more or less an oversight by the standard committee, no one
intended for that to be the case.


Yes, I've heard that before.
In fact all the examples in the
standard (while not normative) use std::endl without including
<ostream>.
Yes.

Are you aware of any implementations that require it?


No, but going by 'letter of the law', since the only defined
declaration of 'std::endl' in the standard is in <ostream>,
I would expect that any conforming implementation would
only be required to guarantee the declaration if that
header were included. It's just a question of writing
to the ISO standard or the 'de-facto' one(s). :-)

-Mike
Oct 25 '05 #13

P: n/a
Mike Wahler wrote:

"Default User" <de***********@yahoo.com> wrote in message
news:3s************@individual.net...

That was more or less an oversight by the standard committee, no one
intended for that to be the case.


Yes, I've heard that before.


It didn't seem like it was addressed in the 2003 update to the
Standard. I originally heard from Dr. Stroustrup about it in when I
queried him in 2002 about this.

He still has an entry on his errata page for TC++PL on the matter.

Brian
Oct 25 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.