Assuming adnumber
is a user defined type (i.e., not a typedef
) defined in namespace ead
, the function max()
should be searched namespaces ead
and std
. Of course, std::max()
is a perfect match, i.e., it wins overload resolution unless adnumber
happens to be a typedef
for ExprWrap<T>
for some type T
. Here is a boiled down example showing the different cases:
#include <iostream>
namespace ead
{
template <typename T> struct ExprWrap {};
template <typename T>
void max(ExprWrap<T> const&) { std::cout << "ead::max()\n"; }
typedef int builtin;
struct other {};
typedef ExprWrap<int> instance;
struct derived: ExprWrap<int> {};
}
namespace foo
{
template <typename T>
void max(T const&) { std::cout << "foo::max()\n"; }
}
int main()
{
using namespace foo;
using namespace ead;
ead::builtin b;
ead::other o;
ead::instance i;
ead::derived d;
max(b);
max(o);
max(i);
max(d);
}
This should print
foo::max()
foo::max()
ead::max()
foo::max()