P
PengYu.UT
#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;
}
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;
}