Take following code as an example
#include <algorithm>
namespace baz {
template<class T>
void sort(T&&){}
}
namespace boot {
const auto sort = [](auto &&){};
}
void foo (){
using namespace std;
using namespace baz;
sort(1);
}
void bar(){
using namespace std;
using namespace boot;
sort(1);
}
I expected that since foo
compiled, then bar
shall compile as well. To my surprise, the foo
compiles correctly and bar
has problem with ambiguous call to sort
function. Am I doing something illegal here or this is proper way compiler should behave? If so, why is it so different. I though generic lambda can be treated as syntactic sugar for generic function.