Is there a reason why function overload across different namespace is not permitted?

  ambiguous-call, c++, c++17, namespaces, overloading

Given the code

#include <boost/hana/transform.hpp>
#include <range/v3/view/transform.hpp>
#include <vector>
using namespace boost::hana;
using namespace ranges::views;
int main(){
    std::vector<int> v{};
    auto constexpr one = [](auto const&){ return 1; };
    auto w = v | transform(one);
}

the error is Reference to 'transform' is ambiguous.

I know I’ve brought both transforms in scope via using directives, but how how could the specific case above be ambiguous? boost::hana::transform takes 2 arguments no matter what, so why can’t the compiler resolve at compile time that I’m trying to use ranges::views::transform via overload resoultion, i.e. based on the fact that I’m feeding it one argument only?

Source: Windows Questions C++

LEAVE A COMMENT