Connecting Tech Pros Worldwide Help | Site Map

rel_ops and namespace

 
LinkBack Thread Tools Search this Thread
  #1  
Old September 26th, 2007, 04:45 AM
PengYu.UT@gmail.com
Guest
 
Posts: n/a
Default rel_ops and namespace

#include <iostream>
Hi,

I don't understand why "using" in namespace A is not working. I would
assume it is more reasonable to use Koenig lookup (http://
en.wikipedia.org/wiki/Argument_dependent_name_lookup).

For B is defined in namespace A, shall it be OK to using "rel_ops" in
A instead of the global namespace?

Thanks,
Peng

#include <utility>

namespace A {

// using namespace std::rel_ops; // not working
class B {
public:
B(int b):_b(b) { }
bool operator==(const B& b) const {
return _b == b._b;
}
private:
int _b;
};
}

using namespace std::rel_ops; // works

int main() {
A::B b1(10);
A::B b2(10);
std::cout << (b1 == b2) << std::endl;
std::cout << (b1 != b2) << std::endl;
}


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.