Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

14.6.2 Dependent Names

The Visual C++ compiler does not currently support binding nondependent names when initially parsing a template. This can cause overloads to be declared after the template (but before the template is instantiated) to be seen.

// DependentNames.cpp
#include <stdio.h>
namespace N {
   void f(int) { printf("f(int)\n");}
}

template <class T> void g(T) {
   N::f('a');   // calls f(char) should call f(int)
}

namespace N {
   void f(char) { printf_s("f(char)\n");}
}

int main() {
   g('c');
}

Output

f(char)
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.