I have a class with template function and a special function, which looks like:
#include <bits/stdc++.h>
using namespace std;
class A
{
public:
template <typename T>
void test(const T& t)
{
cout << "template " << t << endl;
}
void test(const std::string& s) {
cout << "test " << s << endl;
}
};
int main()
{
A a;
a.test("asdas");
}
As you could see, there are two test function:
templatefunction- special function which only match
std::stringinput.
What I want is:
test(1)-> calltemplatefunctiontest<int>(1)std::string str = "asd"; test(str);-> call special functiontest(str)test("asd")-> call special functiontest(std::string str = "asd")
How to achieve this?