I have something like this:
#include <iostream> namespace N { typedef std::pair<int, double> MyPair; std::ostream& operator << (std::ostream& o, MyPair const & mypair) { /// } } int main() { N::MyPair pr; std::cout << pr; }
This, of course, does not work because ADL will not find operator<< , because namespace N not associated with MyPair (unfortunately). Afaik cannot be added to the std namespace, so if I decided to define operator << in std, that would be illegal. So ... what to do in such situations? I do not want to explicitly qualify operator << , and I do not want to write using namespace N So the questions are:
- How to reorganize the code?
- Why doesn't ADL bind typedefs namespaces? Serious reasons? It would be nice, for example. in this case. Thanks
c ++ typedef argument-dependent-lookup
Armen Tsirunyan Nov 11 '10 at 2:35 a.m. 2010-11-11 14:35
source share