Connecting Tech Pros Worldwide Help | Site Map

rel_ops and namespace

  #1  
Old September 26th, 2007, 05:45 AM
PengYu.UT@gmail.com
Guest
 
Posts: n/a
#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;
}

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why there is just one namespace 'std' in the std library? bb answers 1 September 7th, 2007 08:55 AM
How the comparison operators are defined for iterator and const_iterator PengYu.UT@gmail.com answers 2 October 23rd, 2005 05:45 PM
What is wrong with the following program? PengYu.UT@gmail.com answers 1 October 22nd, 2005 04:25 AM
help needed: defining my own ostream manipulators paul.wilkins@gmail.com answers 3 July 23rd, 2005 12:46 AM