koenig-lookup

What is the preference of function/method/template name resolving in C++?

How does the C++ compiler decide which function/method to call if there are multiple possibilities? In my specific case I have the standard free function of the C++ Run time and I also have a templated free variant, like this: // The definitions of the C++ Run Time Library (from memory.h) extern malloc(size_t s); extern void free(void *...

Why doesn't ADL find function templates?

What part of the C++ specification restricts argument dependent lookup from finding function templates in the set of associated namespaces? In other words, why does the last call in main below fail to compile? namespace ns { struct foo {}; template<int i> void frob(foo const&) {} void non_template(foo const&) {} } int main(...

What are the pitfalls of ADL?

Some time ago I read an article that explained several pitfalls of argument dependent lookup, but I cannot find it anymore. It was about gaining access to things that you should not have access to or something like that. So I thought I'd ask here: what are the pitfalls of ADL? ...

Best ADL match between const char * and const char (& p)[T_Size]

I have two functions : void foo(const char * p) and template<size_t T_Size> void foo(const char (& p)[T_Size]) ; Given the call: int main(int argc, char* argv[]) { char a[21] ; // typeid : A21_c sprintf(a, "a[21] : Hello World") ; const char * b = "b : Hello World" ; // typeid : PKc // note ...