Open
Description
template<typename T>
void foo(T x) { std::cout << "Template: " << x << "\n"; }
int main() {
foo(42); // OK: `Template: 42`
foo("hello"); // BAD: `Template: hello` (`const char*: hello` expected)
}
// defined after it's being used
void foo(const char* s) { std::cout << "const char*: " << s << "\n"; }
Possible fix is to declare foo(const char* s)
before main
function.
Another fix is to move foo(const char* s)
definition before main
function.
The idea for this check was inspired by the article by @akrzemi1.