
Zachary Turner wrote:
John Bytheway wrote:
You could put them in the global namespace? I think that would conform better to the letter of the rules, without really being any safer in practice. I'd rather put them in a library specific namespace in that case, and require the programmer to put a using declaration in the translation unit.
Below is an example of why that won't work for all cases. The only way for variant::operator<< to access operator<<(vector) is to rely on ADL and put the operator<< in the std namespace. #include <boost/variant.hpp> #include <iostream> #include <vector> namespace explore { template<typename T> std::ostream& operator<<(std::ostream& ostr, const std::vector<T>& v) { // ... return ostr; } } int main() { using namespace explore; boost::variant<std::vector<int> > v; std::cout << v << std::endl; } -- Jeff Faust