"using"

V

Victor Bazarov

Alex said:
Is it legal to do this:

using std::eek:ut, std::cin, std::endl;
No.

If not, why not?

Because the Standard says so. If you need rationale behind that
particular part of the Standard, ask in comp.std.c++.

V
 
A

Alf P. Steinbach

* Alex Buell:
Is it legal to do this:

using std::eek:ut, std::cin, std::endl;

Does it compile?

If not, then you can be reasonably sure it's not "legal", in the sense
of valid standard C++.

But if it does compile, you'll have to check the standard, that is, Read
The [beep] Documentation.

If not, why not?

If not, then it's not part of the syntax of the language.
 
N

Neil Cerutti

Is it legal to do this:

using std::eek:ut, std::cin, std::endl;

It's probably legal; you should ask a lawyer. But it's an error in
C++. ;-)
If not, why not?

C++'s namespaces are not a module system. They are a lower-level
feature than that, providing the simplest possible tools to prevent
name-clashes in arbitrary code. Your proposal, while convenient, isn't
part of a complete and minimal interface.

Moreover, I'd want something even more convenient:

using (std) out, cin, endl;
 
O

osmium

Alex Buell said:
Is it legal to do this:

using std::eek:ut, std::cin, std::endl;

No, and it's a pain. If you are freaked out about using namespace std, the
best workaround I know of is to put a bunch of the ones you use in a header
file, keep it handy, and add the header when needed. I would make it the
last header file included.
 
A

Alex Buell

No, and it's a pain. If you are freaked out about using namespace std, the
best workaround I know of is to put a bunch of the ones you use in a header
file, keep it handy, and add the header when needed. I would make it the
last header file included.

I'm not in the least bit freaked out using namespaces, it's just
irritating sometimes to have to pull in just the ones you want to use
if you can't use 'using namespace std' instead.
 
R

Roland Pibinger

No, and it's a pain. If you are freaked out about using namespace std,

Why should you? You can write 'using namespace xyz' in all *.cpp files
and explicitly qualify in the rare case of a name clash.
the
best workaround I know of is to put a bunch of the ones you use in a header
file, keep it handy, and add the header when needed. I would make it the
last header file included.

.... or just 'using namespace xyz'

Best wishes,
Roland Pibinger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top