473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

argument dependent lookup

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
13 1818
* 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

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

"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
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
* 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
> "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
"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
* 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

"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
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
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

"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
2
by: adebaene | last post by:
Hello all, I just checked that the following did compile with VC2005 b2, and I think it shouldn't: template <typename T> struct A { typedef int Foo; };
5
by: jcrouse | last post by:
I have the following code: Dim MyStartupArguments() As String MyStartupArguments = System.Environment.GetCommandLineArgs UBound(MyStartupArguments) RomName =...
10
by: lorirobn | last post by:
Hi, I have a form with several combo boxes, continuous form format, with record source a query off an Item Table. The fields are Category, Subcategory, and Color. I am displaying descriptions,...
11
by: Niels Dekker - no reply address | last post by:
The following attempt to pass my template "Base" as a template template argument was rejected by Microsoft VC++ 8.0 (2005), while it still works on VC++ 7.1 (2003). Is it correct C++? And is...
4
by: lutorm | last post by:
Hi all, I'm having a problem writing template functions that take vector<T>::iterator as arguments and I'm sure you guys can set me straight. Like this: #include<vector> using namespace std; ...
10
by: Immortalist | last post by:
Various aquisition devices that guide learning along particular pathways towards human biases. And as E.O. Wilson might say mental development appears to be genetically constrained. (1) Language...
6
by: Mikhail T. | last post by:
Hello! The Tcl's Tcl_SetFromAnyProc type is defined (in tcl.h) as: typedef int (Tcl_SetFromAnyProc) _ANSI_ARGS_((Tcl_Interp *interp, struct Tcl_Obj *objPtr)); The function's purpose is: ...
4
by: siddhu | last post by:
Dear experts, As far as I understood the ADL concept things should work in the following way. I have a global ostream operator defined as //ostreamtest.cpp #include<iostream> using...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.